I created a toggle button in WPF. Each state is represented by an image. It looks like that:
<ToggleButton Click="ButtonEnable_Click" x:Name="ButtonEnable" Width="36" Height="36" ToolTipService.ShowOnDisabled="true" >
<ToggleButton.Resources>
<BitmapImage x:Key="imgNormal" UriSource="/Project;component/Resources/images/Image-active.png"/>
<BitmapImage x:Key="imgChecked" UriSource="/Project;component/Resources/images/Image-inactive.png"/>
</ToggleButton.Resources>
<ToggleButton.Style>
<Style TargetType="ToggleButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Image x:Name="PART_Image" Source="{StaticResource imgNormal}"/>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="PART_Image" Property="Source" Value="{StaticResource imgChecked}"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="PART_Image" Property="Source" Value="{StaticResource imgNormal}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Style>
</ToggleButton>
And everything works fine. But i want to create a tooltip for each state of my togglebutton. One "Active, blabla". And the other "Inactive blabla". And my software has to be localized, so the text of the tooltip is based on a ressource (en, fr, de, etc).
From what i saw, i am pretty sure it's a simple keyword or something... But i don't know what keyword, and where i have to put it...
Thanks a lot. Bye.
Use Style
something like:
<Trigger Property="IsChecked" Value="True">
<Setter Property="ToolTip" Value="{x:Static local:MainWindow.Tooltip1}"/>
</Trigger>
<Trigger Property="IsChecked" Value="False">
<Setter Property="ToolTip" Value="{x:Static local:MainWindow.Tooltip2}"/>
</Trigger>
Property: Use CLR property
to get values from Resource file
private static string tooltip1;
public static string Tooltip1
{
get
{
if (tooltip1 == null)
{
tooltip1 = "";//get this value form Resources
}
return tooltip1;
}
}