Name: Anonymous 2014-02-05 18:25
Hi guys, I've asked this on a few forums but I'm not getting any replies. Can someone please help me work out why the VisualBrush in the following code doesn't display?
<ControlTemplate TargetType="TextBox" x:Key="textBoxTemplate_watermark" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<TextBox x:Name="TextBox1" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderBrush="#FFC9CBD1" />
<ControlTemplate.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<Label Background="Black" Padding="10,0,0,0" Content="{Binding ElementName=TextBox1, Path=ToolTip}" Foreground="Gray" />
</VisualBrush.Visual>
</VisualBrush>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="TextBox" x:Key="textBoxTemplate_watermark" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<TextBox x:Name="TextBox1" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderBrush="#FFC9CBD1" />
<ControlTemplate.Resources>
<VisualBrush x:Key="CueBannerBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<Label Background="Black" Padding="10,0,0,0" Content="{Binding ElementName=TextBox1, Path=ToolTip}" Foreground="Gray" />
</VisualBrush.Visual>
</VisualBrush>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource CueBannerBrush}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>