Is there a good PropertyGrid implementation I could use in my applications?
This blog has a good PropertyGrid implementation: Your own WPF PropertyGrid control in a couple of hours
How do I create a template programatically?
You can create a template programatically by populating the VisualTree of the template. [C#] DataTemplate template = new DataTemplate(); template.VisualTree = new FrameworkElementFactory(typeof(Path)); template.VisualTree.SetBinding(Path.StrokeProperty, new Binding(‘Stroke’)); template.VisualTree.SetBinding(Path.StrokeThicknessProperty, new Binding(‘StrokeThickness’)); template.VisualTree.SetBinding(Path.FillProperty, new Binding(‘Interior’)); template.VisualTree.SetBinding(Path.DataProperty, new Binding(‘Geometry’));
How do I filter out duplicate entries in my list when bound to a data source?
The fact that you have duplicate entries probably suggests that you are binding to the wrong data source. But, in any case, there are possibly valid scenarios where this is necessary. Here is a solution. One way is to group the list by name using CollectionViewSource and then bind the Groups to the ListBox. Here is some code: (for better code formatting, look at this thread: Distinct Value Filter For ListBox If you Contracts collection is like this: [C#] public class Contracts : List { public Contracts() { this.Add(new Contract() { ContractKey = ‘1’, Name = ‘John’ }); this.Add(new Contract() { ContractKey = ‘2’, Name = ‘Bill’ }); this.Add(new Contract() { ContractKey = ‘3’, Name = ‘Bill’ }); } } public class Contract { public string ContractKey { get; set; } public string Name { get; set; } } Then you can use the CollectionViewSource to bind to it and group the colelction by Name as follows: [XAML] This will render the listbox the way you want – ignoring the duplicate names. You can then interpret the selected item as follows: [XAML] private void lb_SelectionChanged(object sender, SelectionChangedEventArgs e) { CollectionViewGroup groupSelected = ((CollectionViewGroup)e.AddedItems[0]); string name = groupSelected.Name; // These contain the items within the group //groupSelected.Items; }
How do I execute 2 animations in parallel?
You can do so by first making the 2 animations a child of a single storyboard as follows: <BeginStoryboard> <Storyboard x:Name=’Animation’> <Storyboard x:Name=’FadeInStoryboard’/> <Storyboard x:Name=’FadeOutStoryboard’/> </Storyboard </BeginStoryboard>
How do I create in-line event handlers?
Here are some examples: Example 1: animation.Completed += delegate { // Start the other animation after the end of the previous animation. index++; if (lstDefinitions.Count > index) this.PerformAnimations(index, lstDefinitions); }; Example 2: label.MouseDown += (sender, e) => { Console.WriteLine(‘MouseDown:{0}’, e.OriginalSource); //Not clear why this is needed, but I guess this can effectively bypass // any attempt from the parent control to capture the mouse inside MouseDown handler. e.Handled = true; };