I've just started learning WPF. However, now I'm having issues with my UI (which remains empty). This is the code I'm using; What I'm trying to do is to display the properties of the River in the UI.
<Window.Resources>
<local:River x:Key="theRiver" Name="Colorado River" MilesLong="1450" />
<StackPanel x:Key="stackey" DataContext="theRiver">
<StackPanel.Resources>
<DataTemplate x:Key="key" DataType="{x:Type local:River}" >
<Border x:Name="bdr" BorderBrush="Blue" BorderThickness="3" CornerRadius="12" Padding="2">
<Grid Margin="5">
<TextBlock x:Name="txt" FontFamily="Bookman old style">
<Run Text="The"/>
<TextBlock Text="{Binding Name}"/>
<Run Text="is"/>
<TextBlock Text="{Binding MilesLong}" />
<Run Text="miles long." />
</TextBlock>
</Grid>
</Border>
<DataTemplate.Triggers>
<Trigger SourceName="bdr" Property="IsMouseOver" Value="True">
<Setter TargetName="bdr" Property="Background" Value="Red"/>
<Setter TargetName="txt" Property="Foreground" Value="Green"/>
<Setter TargetName="bdr" Property="CornerRadius" Value="40"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</StackPanel.Resources>
</StackPanel>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--<StackPanel Grid.Column="1" Grid.Row="1" Margin="10" Background="Gold" DataContext="{StaticResource theRiver}>-->
<ContentControl Content="{StaticResource ResourceKey=stackey}" Grid.Column="1" Grid.Row="1" Margin="10" Background="Gold" />
</Grid>
There are a few issues in your code.
<StackPanel x:Key="stackey" DataContext="theRiver">
<StackPanel.Resources>
<DataTemplate x:Key="key" DataType="{x:Type local:River}" >
Here you want to provide an unnamed DataTemplate for the type that will be loaded into the ContentControl. The StackPanel wrapper here is unnecessary, as is the x:Key on the DataTemplate.
<ContentControl Content="{StaticResource ResourceKey=stackey}"
This says that the source for the ContentControl's content is the StackPanel you declared in your resources, rather than an instance of River.
Corrected/working code looks like:
<Window.Resources>
<local:River x:Key="theRiver" Name="Colorado River" MilesLong="1450" />
<DataTemplate DataType="{x:Type local:River}">
<Border x:Name="bdr"
BorderBrush="Blue"
BorderThickness="3"
CornerRadius="12"
Padding="2">
<Grid Margin="5">
<TextBlock x:Name="txt" FontFamily="Bookman old style">
<Run Text="The" />
<TextBlock Text="{Binding Name}" />
<Run Text="is" />
<TextBlock Text="{Binding MilesLong}" />
<Run Text="miles long." />
</TextBlock>
</Grid>
</Border>
<DataTemplate.Triggers>
<Trigger SourceName="bdr" Property="IsMouseOver" Value="True">
<Setter TargetName="bdr" Property="Background" Value="Red" />
<Setter TargetName="txt" Property="Foreground" Value="Green" />
<Setter TargetName="bdr" Property="CornerRadius" Value="40" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- <StackPanel Grid.Column="1" Grid.Row="1" Margin="10" Background="Gold" DataContext="{StaticResource theRiver}> -->
<ContentControl Grid.Row="1"
Grid.Column="1"
Margin="10"
Background="Gold"
Content="{Binding Source={StaticResource theRiver}}" />
</Grid>
Just define the DataTemplate in Windows.Resources like below (remove the Stackpanel):
<DataTemplate x:Key="stackey" DataType="{x:Type local:River}" >
<Border x:Name="bdr" BorderBrush="Blue" BorderThickness="3" CornerRadius="12" Padding="2">
<Grid Margin="5">
<TextBlock x:Name="txt" FontFamily="Bookman old style">
<Run Text="The"/>
<TextBlock Text="{Binding Name}"/>
<Run Text="is"/>
<TextBlock Text="{Binding MilesLong}" />
<Run Text="miles long." />
</TextBlock>
</Grid>
</Border>
<DataTemplate.Triggers>
<Trigger SourceName="bdr" Property="IsMouseOver" Value="True">
<Setter TargetName="bdr" Property="Background" Value="Red"/>
<Setter TargetName="txt" Property="Foreground" Value="Green"/>
<Setter TargetName="bdr" Property="CornerRadius" Value="40"/>
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
and then bind your ContentControl like
<ContentControl Grid.Column="1" Grid.Row="1" DataContext="{StaticResource theRiver}" Content="{StaticResource theRiver}" ContentTemplate="{StaticResource stackey}" Margin="10" Background="Gold" />
Related
I have a problem with nested template bindings.
Having an ItemsControl with a template, which works great. This template contains a tooltip as well (which shows perfectly).
<Button.ToolTip>
<TextBlock Text="{Binding Path=DetailPaneText}" />
</Button.ToolTip>
But inside the itemscontrol template, I have a ToggleButton with another template inside it. And I can't seem to show the text over there as well since the binding isn't correct.
Code inside the toggle button
<StackPanel Background="#293344" Width="200" x:Name="DetailTab" Margin="0">
<TextBlock FontSize="12" Text="" Foreground="White" />
</StackPanel>
What kind of binding or syntax should I put in between the Text tags? I tried several options but none of them seemed to work yet. Currently out of guesses.
Thanks
Complete code snippet
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0" >
<Button Command="{x:Static CobraInfrastructure:Commands.NavigateFromBreadcrumb}" CommandParameter="{Binding Path=Current}" Tag="{Binding DetailPaneText}" x:Name="TextBlock_Detail" Style="{DynamicResource BreadcrumbButton}">
<Button.Resources>
<Style BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
<Setter Property="Background" Value="#F8F8F8" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="Padding" Value="15" />
<Setter Property="MinWidth" Value="300" />
<Setter Property="MinHeight" Value="150" />
<Setter Property="VerticalAlignment" Value="Top" />
</Style>
</Button.Resources>
<Button.ToolTip>
<TextBlock Text="{Binding Path=DetailPaneText}" />
</Button.ToolTip>
<Grid Margin="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="HyphenTextBlock" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Text="{Binding Path=EntityTitle}" FontSize="12" FontWeight="Bold" Foreground="White" Grid.Row="0" Grid.Column="0"/>
<TextBlock VerticalAlignment="Stretch" Text="{Binding Path=Text, NotifyOnTargetUpdated=True, Mode=OneWay}" FontSize="10" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"/>
</Grid>
</Button>
<ToggleButton Focusable="False" Style="{DynamicResource BreadcrumbOpenButton}" VerticalAlignment="Stretch" HorizontalAlignment="Center" Tag="{Binding Path=DetailPaneText}">
<ToggleButton.Template>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel Orientation="Horizontal">
<Border Width="13" Background="#293344">
<fa:FontAwesome Icon="CaretRight" Foreground="White" FontSize="18" VerticalAlignment="Center" HorizontalAlignment="Center" />
</Border>
<StackPanel Background="#293344" Width="200" x:Name="DetailTab" Margin="0">
<TextBlock FontSize="12" Text="" Foreground="White" />
</StackPanel>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Width" TargetName="DetailTab" Value="200"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="Width" TargetName="DetailTab" Value="1"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</ToggleButton.Template>
</ToggleButton>
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding IsVisible}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
<DataTrigger Binding="{Binding IsOverview}" Value="True">
<Setter Property="Style" TargetName="TextBlock_Detail" Value="{DynamicResource LinkButton}" />
<Setter Property="FontWeight" TargetName="TextBlock_Detail" Value="Bold" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
You should reference on TemplatedParent in Binding:
<StackPanel Background="#293344" Width="200" x:Name="DetailTab" Margin="0">
<TextBlock FontSize="12" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataContext.DetailPaneText}" Foreground="White" />
</StackPanel>
If you trying to bind a tooltip text of a button to the Text property of textblock, you may bind it using the ElementName.
First name your button using x:Name
<Button x:Name="XButton">
<Button.ToolTip>
<TextBlock Text="{Binding Path=DetailPaneText}" />
</Button.ToolTip>
</Button>
Bind it to text block text using the ElementName.
<StackPanel Background="#293344" Width="200" x:Name="DetailTab" Margin="0">
<TextBlock FontSize="12" Text="{Binding ElementName=XButton, Path=ToolTip.Text}" />
</StackPanel>
I have the following Popup:
<Popup Name="popupBind"
AllowsTransparency="True"
Helpers:FocusHelper.IsFocused="{Binding RelativeSource={RelativeSource Self},
Path=IsOpen,
Mode=OneWay}"
HorizontalOffset="-30"
IsOpen="{Binding IsBindingBegun,
Mode=TwoWay}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=bindButton}"
StaysOpen="False"
>
<Border Background="{DynamicResource {x:Static Styles:CommonStyles.ButtonsPanelBackgroundKey}}"
BorderBrush="Black"
BorderThickness="1"
Padding="0">
<StackPanel HorizontalAlignment="Stretch">
<StackPanel.Resources>
<TemplateSelectors:VersionRangeDataTemplateSelector x:Key="VersionRangeDataTemplateSelector" />
<Converters:RangeToVisibilityConverter x:Key="RangeToVisibilityConverter" />
</StackPanel.Resources>
<StackPanel Margin="5,5,5,2"
HorizontalAlignment="Stretch"
Orientation="Horizontal">
<StackPanel.Resources>
<Style TargetType="Button">
<Setter Property="Margin" Value="5" />
</Style>
</StackPanel.Resources>
<Button Command="{Binding BindCommand}"
>
</Button>
<Button Command="{Binding BindCommand}"
>
</Button>
<Button Command="{Binding BindCommand}"
>
</Button>
<Button Command="{Binding BindCommand}"
>
</Button>
</StackPanel>
<ItemsControl Margin="10,2,5,5"
Focusable="False"
Grid.IsSharedSizeScope="True"
ItemTemplateSelector="{StaticResource VersionRangeDataTemplateSelector}"
ItemsSource="{Binding Path=VersionsVm.TempRanges}">
<ItemsControl.Resources>
<Style TargetType="CheckBox">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Padding" Value="0" />
</Style>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="14" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Padding" Value="2" />
</Style>
<DataTemplate x:Key="TwoDistinctVersionsRangeTemplateKey">
<Grid Margin="2,4" HorizontalAlignment="Stretch">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="_1" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_2" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_3" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_4" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_5" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_6" />
<ColumnDefinition Width="Auto" SharedSizeGroup="_7" />
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" IsChecked="{Binding IncludeStartEdge, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Grid.Column="1" Margin="2,0,5,0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IncludeStartEdge}" Value="True">
<Setter Property="Text" Value="[" />
</DataTrigger>
<DataTrigger Binding="{Binding IncludeStartEdge}" Value="False">
<Setter Property="Text" Value="(" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<TextBlock Grid.Column="2"
HorizontalAlignment="Left"
Text="{Binding FromVersionName}"
TextAlignment="Left" />
<TextBlock Grid.Column="3"
Width="10"
Margin="5,0"
HorizontalAlignment="Center"
Text="-"
TextAlignment="Center" />
<TextBlock Grid.Column="4"
HorizontalAlignment="Left"
Text="{Binding ToVersionName}"
TextAlignment="Left" />
<TextBlock Grid.Column="5" Margin="5,0,2,0">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IncludeEndEdge}" Value="True">
<Setter Property="Text" Value="]" />
</DataTrigger>
<DataTrigger Binding="{Binding IncludeEndEdge}" Value="False">
<Setter Property="Text" Value=")" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<CheckBox Grid.Column="6" IsChecked="{Binding IncludeEndEdge, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</Grid>
</DataTemplate>
<DataTemplate x:Key="FixedVersionRangeTemplateKey">
<StackPanel>
<TextBlock Margin="2,4"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{Binding FromVersionName}"
TextAlignment="Left" />
<StackPanel>
<StackPanel.Visibility>
<MultiBinding Converter="{StaticResource RangeToVisibilityConverter}">
<MultiBinding.Bindings>
<Binding />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=UserControl}" />
</MultiBinding.Bindings>
</MultiBinding>
</StackPanel.Visibility>
<RadioButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl},
Path=DataContext.VersionsVm.ChangeTempRangeTypeCommand}"
Content="<" />
<RadioButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl},
Path=DataContext.VersionsVm.ChangeTempRangeTypeCommand}"
Content="<=" />
<RadioButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl},
Path=DataContext.VersionsVm.ChangeTempRangeTypeCommand}"
Content="="
IsChecked="True" />
<RadioButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl},
Path=DataContext.VersionsVm.ChangeTempRangeTypeCommand}"
Content=">=" />
<RadioButton Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType=UserControl},
Path=DataContext.VersionsVm.ChangeTempRangeTypeCommand}"
Content=">" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
</StackPanel>
</Border>
</Popup>
I have a very strange issue with it.
When I hit Tab, Left or Right focus leaves popup and goes to the parent window. Popus stays opened.
I do not know why this happens. But I've got broken keyboard navigation.
The only thing I can suspect to be the reason is that parent of Popup is UserControl hosted inside winforms ElementHost.
I have no idea how to debug this problem so I appreciate any helpful hints.
Thank you in advance.
Having a Binding on IsOpen can override the StaysOpen behavior. I can't tell without seeing more but if that IsOpen binding is persisting a True value from its source that would keep the Popup open no matter what happens with the focus.
I need to set change background color for list item when mouse is over. Here is my code:
<DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}">
<StackPanel>
<Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}"
Content="{Binding Path=sub_category_name}"
Background="Transparent"
Height="25"/>
</StackPanel>
</DataTemplate>
<ControlTemplate x:Key="subCategoryListItems" TargetType="{x:Type Button}">
<StackPanel FlowDirection="LeftToRight" Orientation="Horizontal" >
<TextBlock Width="150"
Height="{TemplateBinding Button.Height}"
x:Name="textBlockSubCategoryName"
Background="{TemplateBinding Button.Background}"
Text="{TemplateBinding Button.Content}"
FontWeight="Bold" />
<Image x:Name="img" Width="15" Height="15" Source="/ExpressFurnitureSystem;component/Images/edit.png" ToolTip="Click to edit"></Image>
</StackPanel>
</ControlTemplate>
Please help...How??
How about a Trigger such as:
<DataTemplate x:Key="ListBoxSubCategoryListTemplate" DataType="{x:Type ListBoxItem}">
<StackPanel>
<Button x:Name="btnSubCategoryList" Template="{StaticResource subCategoryListItems}"
Content="{Binding Path=sub_category_name}"
Background="Transparent"
Height="25"/>
</StackPanel>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="btnSubCategoryList" Property="Background" Value="Blue" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
I have a listbox i want that except first index all other items are scrollable.
I have a sample code here. Here my list box first item is behaing like header of list box. So now i dont want to scroll header. and rest of item's should be scrollable.`
<ListBox x:Name="FieldOrderListBox" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" SelectedIndex="0" IsSynchronizedWithCurrentItem="True"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Hidden" SelectionChanged="FieldOrderListBox_SelectionChanged">
<ListBox.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="#FF479EF3"></SolidColorBrush>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate x:Name="MyTemplate">
<Grid Margin="-5,-1,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="FieldName" MinWidth="10" MaxWidth="300"/>
<ColumnDefinition Width="2"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.Style>
<Style TargetType="{x:Type Grid}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource PreviousData}}" Value="{x:Null}">
<Setter Property="TextBlock.TextAlignment" Value="Center"/> <Setter Property="Background" Value="#E5E5E5"/>
<Setter Property="TextBlock.Foreground" Value="Black"/>
<Setter Property="Border.BorderThickness" Value="0.5,0.5,0,2"/>
<Setter Property="Border.BorderBrush" Value="Black"/>
<Setter Property="Border.Margin" Value="0,-1,0,0"/>
<Setter Property="Border.Padding" Value="5,0,0,5"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Style>
<Border BorderBrush="Black" Grid.Column="0" BorderThickness="0.5,0.0,0.5,0.5" IsHitTestVisible="False" OverridesDefaultStyle="False">
<TextBlock Text="{Binding Name}" Grid.Column="0" ToolTip="{Binding Name}" Margin="5,0,2,0" VerticalAlignment="Center"/>
</Border>
<GridSplitter Grid.Column="1" Width="2" HorizontalAlignment="Left" Background="DarkGray" Margin="-2,0,-1,0"/>
<Border BorderBrush="Black" BorderThickness="0,0.0,0.5,0.5" Margin="-2,0,0,0" Padding="0,5,0,0" Grid.Column="2">
<TextBlock Text="{Binding AliasName}" Grid.Column="1" ToolTip="{Binding AliasName}" Margin="5,0,2,0" VerticalAlignment="Center" HorizontalAlignment="Stretch"/>
</Border>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I've got a data template for a list box item similar to the one on this page...
link
I would like to take it a step further and do something to highlight the items when they change. For example, using the code in the link above, I would like to put a trigger to do something when Widget.Quantity changes. Maybe make the quiantity item (nothing else) flash or something. How can I do that? I include the relevant code below...
<Window.Resources>
<Style x:Key="RoundedItem" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border CornerRadius="10" BorderBrush="Black" BorderThickness="1" Margin="1">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate DataType="{x:Type local:Widget}">
<StackPanel Orientation="Horizontal">
<Label Content="{Binding Name}" />
<Label Content="{Binding Quantity}" />
</StackPanel>
</DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding Widgets}" ItemContainerStyle="{StaticResource RoundedItem}" HorizontalContentAlignment="Stretch" />
Just add triggers to the DataTemplate.Triggers collection.
<DataTemplate DataType="{x:Type local:Widget}">
<StackPanel x:Name="panel" Orientation="Horizontal">
<Label Content="{Binding Name}" />
<Label Content="{Binding Quantity}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding SomeProperty}" Value="True">
<Setter Property="Background" Value="Yellow" TargetName="panel" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
You'll probably want to add a property in your Widget class to do that. Or if Widget is a Model, you may want to wrap it in a WidgetViewModel class with an "IsFlashing" property on it. Then set the trigger to fire whenever this "IsFlashing" property is True.
I've managed to get it working with EventTriggers. Complete code below. In summary, the event trigger detects when the bound value changes, then turns the text orange briefly.
<UserControl.Resources>
<!-- instantiate an instance of the TimeSettingsCollection class -->
<c:TimeSettingsCollection x:Key="TimeSettingsCollection"/>
<Style x:Key="ListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Name="ItemBorder" BorderBrush="Gray" BorderThickness="1" Margin="3" Padding="7" Background="Transparent">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="ItemBorder" Property="Background" Value="LightBlue" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate DataType="{x:Type c:TimeSettingsItem}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Margin="0,0,8,0"
Style="{StaticResource smallTitleStyle}">Pc Name:</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path=PcName}"
Style="{StaticResource textStyleTextBlock}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,0,8,0"
Style="{StaticResource smallTitleStyle}">Time:</TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=TimeSettings.DateTime, NotifyOnTargetUpdated=True}"
Style="{StaticResource textStyleTextBlock}" x:Name="timeTextBlock">
<TextBlock.Background>
<SolidColorBrush Color="Transparent"/>
</TextBlock.Background>
<TextBlock.Triggers>
<EventTrigger RoutedEvent="Binding.TargetUpdated">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="timeTextBlock"
Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
To="Orange"
Duration="0:0:1"
AutoReverse="True"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</TextBlock.Triggers>
</TextBlock>
</Grid>
</DataTemplate>
</UserControl.Resources>
<DockPanel>
<ListBox Name="timeListBox" ItemsSource="{Binding Source={StaticResource TimeSettingsCollection}}" ItemContainerStyle="{StaticResource ListBoxItemStyle}" HorizontalContentAlignment="Stretch" IsSynchronizedWithCurrentItem="True">
</ListBox>
</DockPanel>