I'm having a very annoying problem with my datatemplates, the mouseOver template won't show any of the databound controls, so only the label and textbox are shown on mouseover. Theres no errors so I think I'm just missing something. The code - first one is used as a the Content Template when on MouseOver:
<!-- Data Template used when MouseOver triggered -->
<DataTemplate x:Key="LibraryItem_MouseOver" DataType="{x:Type local:libraryItemObject}">
<DataTemplate.Resources>
<local:ImageConverter x:Key="imageConverter" />
<local:NoInLibraryConverter x:Key="noInLibraryConverter" />
<local:ProjectsUsedInConverter x:Key="projectsUsedInConverter" />
</DataTemplate.Resources>
<!-- Main content container -->
<StackPanel Orientation="Horizontal">
<Image Width="50" Height="20" Source="{Binding Path=ImageRef,
Converter={StaticResource imageConverter}}" />
<Label Content="{Binding Brand}" />
<Label Content="{Binding Code}" />
<Label Content="{Binding Path=ProjectsUsedIn, Converter={StaticResource projectsUsedInConverter}}" />
<Label Content="{Binding Path=NoInLibrary, Converter={StaticResource noInLibraryConverter}}" />
<Label Content="Number To Add:" />
<TextBox Width="50" PreviewKeyUp="TextBox_PreviewKeyUp" Tag="{Binding Path=ProjectsUsedIn, Converter={StaticResource projectsUsedInConverter}}" />
</StackPanel>
</DataTemplate>
And this is the code for the second DataTemplate:
<DataTemplate DataType="{x:Type local:libraryItemObject}">
<DataTemplate.Resources>
<local:ImageConverter x:Key="imageConverter" />
<local:NoInLibraryConverter x:Key="noInLibraryConverter" />
<local:ProjectsUsedInConverter x:Key="projectsUsedInConverter" />
<Style TargetType="Button">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="FontFamily" Value="Verdana"/>
<Setter Property="FontSize" Value="11px"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Background" >
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1" >
<GradientStop Color="#FFFFD190" Offset="0.2"/>
<GradientStop Color="Orange" Offset="0.85"/>
<GradientStop Color="#FFFFD190" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Name="border"
BorderThickness="1"
Padding="4,2"
BorderBrush="DarkGray"
CornerRadius="3"
Background="{TemplateBinding Background}">
<Grid>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center">
<ContentPresenter.RenderTransform>
<TranslateTransform X="1.0" Y="1.0" />
</ContentPresenter.RenderTransform>
</ContentPresenter>
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"
Name="content"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="border" Property="BorderBrush" Value="#FF4788c8" />
<Setter Property="Foreground" Value="#FF4788c8" />
<Setter Property="ContentTemplate" Value="{StaticResource LibraryItem_MouseOver}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataTemplate.Resources>
<Button>
<StackPanel Orientation="Horizontal">
<Image Width="50" Height="20" Stretch="Fill" Source="{Binding Path=ImageRef,
Converter={StaticResource imageConverter}}" />
<Label Content="{Binding Brand}" />
<Label Content="{Binding Code}" />
<Label Content="{Binding Path=ProjectsUsedIn, Converter={StaticResource projectsUsedInConverter}}" />
<Label Content="{Binding Path=NoInLibrary, Converter={StaticResource noInLibraryConverter}}" />
</StackPanel>
</Button>
</DataTemplate>
Any ideas what might be causing the problem? The types are both the same and the converters are specified for both, so I can't work out why the mouseOver data template isn't getting the source properly! Thanks, Becky