We have already alluded to dependency properties, albeit in a Silverlight context. Now we talk about it from the WPF perspective (not too different).
I Bless Thy Command Shell My Child: + {az account list --output table}
Wednesday, 24 October 2012
Wednesday, 17 October 2012
Saving sln files in Visual Studio - UTF-8, Unicode or ANSI?
SAY NO TO ANSI
Anything but ANSI - that's 8 bits and can only hold a limited number of characters (2^8 = 256).
Anything but ANSI - that's 8 bits and can only hold a limited number of characters (2^8 = 256).
To Update an ObservableCollection on a Background Thread or Not To?
ADD, REMOVE, REPLACE - NO
MODIFY - YES
Modifying an ObservableCollection will lead to an event being raised, which is handled on the same thread as the modification. If you add or remove items from an ObservableCollection from a background thread, the event gets raised before the Add/Remove gets completed.
If you are just changing properties in the elements (trivial updates) you should be fine. The processing can happen in the background, and the trivial update can happen on the main thread, no problems. GUI response time should not be impacted.
MODIFY - YES
Modifying an ObservableCollection will lead to an event being raised, which is handled on the same thread as the modification. If you add or remove items from an ObservableCollection from a background thread, the event gets raised before the Add/Remove gets completed.
If you are just changing properties in the elements (trivial updates) you should be fine. The processing can happen in the background, and the trivial update can happen on the main thread, no problems. GUI response time should not be impacted.
protected set
READ ONLY VIEW MODEL FIELD IN BOUND GUI
Making a property setter protected means the property will be non-editable in a GUI control when the data is being used as a ViewModel in the context of data binding.
Making a property setter protected means the property will be non-editable in a GUI control when the data is being used as a ViewModel in the context of data binding.
Domain-neutral Assemblies
BUILD CLEAN SEVERAL TIMES TO CLEAR APPDOMAIN SECURITY ERRORS
What are domain-neutral assemblies?
Domain-neutral assemblies are assemblies designed to work across appdomains. They wil be jitted only once. The idea is to get performance gains in multiple appdomain scenarios. mscorlib is always domain-neutral.
Why are they important?
They are important to understand error messages that come from app domain security messages e.g. on why a particular assembly cannot be loaded when trying to run an application.
What are domain-neutral assemblies?
Domain-neutral assemblies are assemblies designed to work across appdomains. They wil be jitted only once. The idea is to get performance gains in multiple appdomain scenarios. mscorlib is always domain-neutral.
Why are they important?
They are important to understand error messages that come from app domain security messages e.g. on why a particular assembly cannot be loaded when trying to run an application.
Refactoring WPF (IOException: Cannot Locate Resource)
CHECK STARTUPURI
Minimal Structure WPF
What is the minimal structure of a WPF Application, for example, when you go into Visual Studio and click to create a new WPF Application?
This is a guide to a bare-bones WPF application. In fact, you can happily write WPF applications without knowing the bare-bones, but at some point it's essential to look back and fully understand what's going on in order to move forward.
App.xaml, App.xaml.cs and StartupUri (VIRF = Very Important when Refactoring)
Look at App.xaml and App.xaml.cs. This represents a single logical unit, representing the Application (or more precisely a subclass of System.Windows.Application) implemented over two partial classes.
This is like Global.asax in ASP.NET land. It's where you can put shared resources to be shared across multiple windows. It also specifies (in the App.xaml "header element" the StartupUri which will be set to the auto-generated MainWindow.xaml). If you change the StartupUri to something that doesn't except (e.g. PainWindow.xaml instead of MainWindow.xaml you will get an IOException ("Cannot locate resource: PainWindow.xaml"). This can happen after a refactor where you can't decide the name for the MainWindow.xaml and then forget to change the StartupUri (or MSVS fails to change the StartUri automagically - it happens).
App.xaml.cs purports to be the "interaction logic" for App.xaml but in reality it is usually left empty. App.xaml is frequently underutilised in WPF projects and should be given more a higher profile by WPF developers.
MainWindow.xaml and MainWindow.xaml.cs
This contains the window XAML and the IntializeComponent code after which you can define your own initialization logic (e.g. creation of ViewModels etc).
Furthering your Understanding
To understand more completely what a WPF Application actually is, one can read the MSDN document describing System.Windows.Application and its parent classes.
Minimal Structure WPF
What is the minimal structure of a WPF Application, for example, when you go into Visual Studio and click to create a new WPF Application?
This is a guide to a bare-bones WPF application. In fact, you can happily write WPF applications without knowing the bare-bones, but at some point it's essential to look back and fully understand what's going on in order to move forward.
App.xaml, App.xaml.cs and StartupUri (VIRF = Very Important when Refactoring)
Look at App.xaml and App.xaml.cs. This represents a single logical unit, representing the Application (or more precisely a subclass of System.Windows.Application) implemented over two partial classes.
This is like Global.asax in ASP.NET land. It's where you can put shared resources to be shared across multiple windows. It also specifies (in the App.xaml "header element" the StartupUri which will be set to the auto-generated MainWindow.xaml). If you change the StartupUri to something that doesn't except (e.g. PainWindow.xaml instead of MainWindow.xaml you will get an IOException ("Cannot locate resource: PainWindow.xaml"). This can happen after a refactor where you can't decide the name for the MainWindow.xaml and then forget to change the StartupUri (or MSVS fails to change the StartUri automagically - it happens).
App.xaml.cs purports to be the "interaction logic" for App.xaml but in reality it is usually left empty. App.xaml is frequently underutilised in WPF projects and should be given more a higher profile by WPF developers.
MainWindow.xaml and MainWindow.xaml.cs
This contains the window XAML and the IntializeComponent code after which you can define your own initialization logic (e.g. creation of ViewModels etc).
Furthering your Understanding
To understand more completely what a WPF Application actually is, one can read the MSDN document describing System.Windows.Application and its parent classes.
Psychology of XAML
DON'T KNOCK XAML, LEARN IT
Reams and reams of XAML, long XML-based definitions of ControlTemplates and VisualStateManager and StoryBoards, may seem daunting, incomprehensible and unmanageable at first. However, this is a great advancement in computing - as declarative GUI-related information has been isolated and sectioned away from the main imperative and application-related coding. The only time you need to enter into the structured chaos that is XAML is when you need to.
Reams and reams of XAML, long XML-based definitions of ControlTemplates and VisualStateManager and StoryBoards, may seem daunting, incomprehensible and unmanageable at first. However, this is a great advancement in computing - as declarative GUI-related information has been isolated and sectioned away from the main imperative and application-related coding. The only time you need to enter into the structured chaos that is XAML is when you need to.
Subscribe to:
Posts (Atom)