In a WPF app I have a custom control. I would like the ToolTip for objects, derived from this custom control, depends on a value of one of the attributes of this custom control.
Is it possible to declare it in a Control Template of this custom control?
Something like:
<ControlTemplate>
??? // <!--XAML ToolTip declaration -->
...
<ControlTemplate.Triggers>
<Trigger Property="MyProperty" Value="FirstValue">
<Setter ...??? /> // <!--XAML ToolTip text assignment -->
</Trigger>
...
<Trigger Property="MyProperty" Value="SecondValue">
<Setter ...??? /> // <!--XAML ToolTip text assignment -->
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Edited (added):
I have found the solution:
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="MyProperty" Value="FirstValue" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Backgr" Property="ToolTip" Value="Available"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="MyProperty" Value="SecondValue" />
</MultiTrigger.Conditions>
<Setter TargetName="PART_Backgr" Property="ToolTip" Value="Sold"/>
</MultiTrigger>
It is working excellent.
But one problem remained: In fact Value="Available"
and others such values should contain non-latin characters (the application is localized in Russian language). When I am trying to compile it with Value="Свободно"
, I get en error:
'Invalid character in the given encoding.' XML is not valid.
What solution could be to this problem? Maybe I could change somewhere the encoding by which Generic.xaml page compiles? Or change XAML code somehow? (In fact, in every window I have lots of non-latin characters in XAML and everything compiles OK. But, maybe, the problem is in the way they used.)