<Window
x:Class=”DynamicTemplatedTreeViewItem.Window1″
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Title=”Window1″
Height=”300″
Width=”551″>
<Window.Resources>
<ResourceDictionary>
<ControlTemplate x:Key=”SelectedTemplate” TargetType=”{x:Type Control}”>
<Label Content=”{Binding XPath=title}” Foreground=”Red” FontWeight=”Bold” />
</ControlTemplate>
<ControlTemplate x:Key=”DefaultTemplate” TargetType=”{x:Type Control}”>
<Label Content=”{Binding XPath=title}” />
</ControlTemplate>
<DataTemplate x:Key=”template”>
<Control Focusable=”False”>
<Control.Style>
<Style TargetType=”{x:Type Control}”>
<Setter Property=”Template” Value=”{StaticResource DefaultTemplate}” />
<Style.Triggers>
<Trigger Property=”IsMouseOver” Value=”True”>
<Setter Property=”Template” Value=”{StaticResource SelectedTemplate}” />
</Trigger>
</Style.Triggers>
</Style>
</Control.Style>
</Control>
</DataTemplate>
<XmlDataProvider x:Key=”justnbusiness” Source=”http://www.justnbusiness.com/feed.aspx” />
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TreeView
HorizontalAlignment=”Stretch”
x:Name=”treeView”
SelectedValuePath=”description”
BorderBrush=”#00000000″
Background=”#00000000″>
<TreeViewItem
ItemsSource=”{Binding
Mode=Default,
Source={StaticResource justnbusiness},
XPath=/rss/channel/item}”
ItemTemplate=”{StaticResource template}”
Header=”Blog Posts”/>
</TreeView>
<Border
Grid.Column=”1″
CornerRadius=”5,5,5,5″
BorderThickness=”1,1,1,1″
BorderBrush=”#FF000000″
Padding=”5,5,5,5″
Margin=”20,20,20,20″>
<TextBlock
Text=”{Binding
Path=SelectedValue,
ElementName=treeView,
Mode=Default}”
TextWrapping=”Wrap”/>
</Border>
</Grid>
</Window>
|
You must be logged in to post a comment.