What are the best practices for implementing a localizable application?
This Code project article provides a good overview of the different ways of localizing an application based on specific cultures: WPF Runtime Localization
How do I bind to a dictionary including the ability to get notifications when items are added or removed?
Dictionaries are very easy to work with in code and are useful in variety of scenarios. Being able to bind to it along with the ability to get notifications when items get added or removed is a very useful capability. This article provides you an ObservableDictionary that does the same: Dr.WPF: Can I bind my ItemsControl to a dictionary?
How do I programatically interact with template generated elements?
Getting hold of an element in a ControlTemplate is very easy, as this article explains: How do I programmatically interact with template-generated elements? Part I Sample code: Grid gridInTemplate = (Grid)myButton1.Template.FindName('grid', myButton1); But, if want to get hold of an item in a DataTemplate (which gets applied for each item in the ItemsControl), then there is more code involved as explained here: How do I programmatically interact with template-generated elements? Part II Sample Code: // Note that the ListBox must have // IsSynchronizedWithCurrentItem set to True for this to work ListBoxItem myListBoxItem = (ListBoxItem)(myListBox.ItemContainerGenerator.ContainerFromItem(myListBox.Items.CurrentItem)); ContentPresenter myContentPresenter = FindVisualChild<contentpresenter>(myListBoxItem); DataTemplate myDataTemplate = myContentPresenter.ContentTemplate; TextBlock myTextBlock = (TextBlock)myDataTemplate.FindName('textBlock', myContentPresenter); </contentpresenter>
How can I create a ControlTemplate for a HeaderedItemsControl ?
ControlTemplate can be created for a HeaderedItemsControl as follows. [XAML] <!--Define a control template for a HeaderedItemsControl--> <Style TargetType='HeaderedItemsControl'> <Setter Property='Template'> <Setter.Value> <ControlTemplate TargetType='{x:Type HeaderedItemsControl}'> <StackPanel> <Grid> <Rectangle Fill='{TemplateBinding Background}'/> <ContentPresenter ContentSource='Header'/> </Grid> <Grid> <Rectangle Stroke='{TemplateBinding BorderBrush}'/> <ItemsPresenter Margin='2,0,0,0'/> </Grid> </StackPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> ... <HeaderedItemsControl xmlns:sys='clr-namespace:System;assembly=mscorlib' Header='My colors' Background='SteelBlue' BorderBrush='DarkSlateBlue'> <sys:String>Red</sys:String> <sys:String>Yellow</sys:String> <sys:String>Blue</sys:String> <sys:String>Green</sys:String> </HeaderedItemsControl>
How do I add custom controls to an application using Microsoft Expression Blend ?
Expression Blend supports custom controls to be added to a WPF application. To add a custom control to a WPF application the following steps have to be performed. 1. Select Add Reference from Project Menu. 2. Browse and select the dll that contains the definition of the custom control. 3. Select Asset library from toolbox. 4. Select custom controls tab and select the necessary control from the list.