How do I view the XAML resources compiled into an assembly in BAML format?

Embedded XAML Resources Several WPF assemblies come with embedded XAML resources, like template definitions, style definitions, etc. And it’s often very useful to take a look at these embedded XAML to understand the structure of a control and thereby making it easier to customize it’s UI in your applications, if necessary. The best way to take a look at these embedded XAML resources is to use the Reflector tool with the BAML Viewer plugin. Reflector + BAML Viewer Reflector is a popular Free tool available since the early days of .NET to help you take a deeper look at the source and resources comprising a .NET assembly. Reflector can be downloaded here: .NET Reflector Here is a thumbnail view of the Reflector tool:\ Once you install the Reflector, download the BAML Viewer plug-in from: BAML Viewer – Reflector Plugin The plug-in is a single dll called Reflector.BamlViewer.dll. Put this dll next to the Reflector.exe and follow these steps to add the plug-in to the Reflector: a) In the Reflector tool, select the View/Add Ins… menu item. b) In the ‘Add Ins’ dialog box, Add the above dll as an ‘add-in’. This will include a new ‘Tools/BAML Viewer’ menu item in the Reflector. c) Then open a WPF assembly (or Syncfusion assembly) that usually contains a BAML resource, like PresentationFramework.Aero.dll (usually found under ‘%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Aero.dll’) d) Then select the ‘Tools/BAML Viewer’ menu item. This will open a new ‘BAML Viewer’ view showing the embedded XAML in the above assembly. Here is a screenshot of the BAML Viewer showing the embedded XAML in the PresentationFramework.Aero.dll:\ You can similarly view XAML resources embedded into Syncfusion assemblies.

How do I show tooltips for the listview items?

You can do so by first defining a DataTemplate for the corresponding columns as follows. Sample code can be seen with better formatting in this thread (ListView Column ToolTip) [XAML] <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> <StackPanel> <StackPanel.Resources> <DataTemplate x:Key='nameTemplate'> <TextBlock Text='{Binding Name}' Margin='-6,0'> <TextBlock.ToolTip> <ToolTip> <TextBlock Foreground='Green' Text='{Binding Name}'/> </ToolTip> </TextBlock.ToolTip> </TextBlock> </DataTemplate> <DataTemplate x:Key='namespaceTemplate'> <TextBlock Text='{Binding Namespace}' Margin='-6,0'> <TextBlock.ToolTip> <ToolTip> <TextBlock Foreground='Green' Text='{Binding Namespace}'/> </ToolTip> </TextBlock.ToolTip> </TextBlock> </DataTemplate> </StackPanel.Resources> <ListView> <ListView.ItemContainerStyle> <Style TargetType='ListViewItem'> <Setter Property='HorizontalContentAlignment' Value='Stretch'/> <Setter Property='VerticalContentAlignment' Value='Stretch'/> </Style> </ListView.ItemContainerStyle> <ListView.View> <GridView> <GridViewColumn CellTemplate='{StaticResource nameTemplate}' Width='300' Header='Name'/> <GridViewColumn CellTemplate='{StaticResource namespaceTemplate}' Width='300' Header='Namespace'/> </GridView> </ListView.View> <x:Type TypeName='Visual'/> <x:Type TypeName='FrameworkElement'/> <x:Type TypeName='FrameworkContentElement'/> </ListView> </StackPanel> </Page>

How do I obtain a reference to the child TreeViewItems of a parent TreeViewItem?

It’s a bit tricky because WPF doesn’t ‘realize’ the child nodes until they get rendered and you will also have to use some not very straight forward APIs to obtain the child. So, you will have to do something like this: // First set IsExpanded to true. tviParent.IsExpanded = true; // Then wait for the child items to get generated if (tviParent.ItemContainerGenerator.Status != System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated) tviParent.ItemContainerGenerator.StatusChanged += new EventHandler(TempItemContainerGenerator_StatusChanged); else // If child items are already generated this.OnReadyToSelect(); private void OnReadyToSelect() { // Here you can obtain and select any child of the currently selected TreeViewItem using it’s ItemContainerGenerator. TreeViewItem childItem = tviParent.ItemContainerGenerator.ContainerFromItem(collectionItem); //Or specify an index. childItem.IsSelected = true; }

How do I specify a HierarchicalDataTemplate for a templated type?

Sometimes you might have to specify a HierarchicalDataTemplate for a templated type. If so, you can only do this in code-behind. (If you have to do this in XAML try wrapping that template type within a non-templated dummy type.) For example, if you have to do something like this: <HierarchicalDataTemplate ItemsSource='{Binding}' DataType='{x:Type local:MyTemplatedList<int>}'> <TextBlock Text='{Binding Name}'></TextBlock> </HierarchicalDataTemplate> The above wouldn’t compile because the XAML compiler doesn’t support this. So, you will have to do this in code-behind instead: using MyListType = MyTemplatedList<int>; // Then in Window’s constructor for example: HierarchicalDataTemplate hdt = new HierarchicalDataTemplate(typeof(MyListType)); hdt.ItemsSource = new Binding(); FrameworkElementFactory tb = new FrameworkElementFactory(typeof(TextBlock)); tb.SetBinding(TextBlock.TextProperty, new Binding('Name')); hdt.VisualTree = tb; this.Resources[new DataTemplateKey(typeof(CountryList))] = hdt; </int> Note that the above code also illustrates how to add a HierarchicalDataTemplate resource to the Resources list without specifying a key.