Reputation: 23303
I have a style with a Trigger for IsMouseOver
, and I want to trigger that Trigger (heh) from C#. How can this be done? Thanks in advance!
Upvotes: 2
Views: 489
Reputation: 28738
You can create a DataTrigger
and then bind to a property in your ViewModel.
First create a bool
property that will advise the View whether it should 'show' or 'not show' your style.
public bool GridTrigger
{
get { return this.gridTrigger; }
set { // raise a PropertyChange event, as per normal
}
And then add the DataTrigger
to the XAML
<Grid.Triggers>
<DataTrigger Binding="{Binding GridTrigger}" Value="True">
<Setter Property="Style" Value="{StaticResource MyMouseOverStyle"/>
</DataTrigger>
</Grid.Triggers>
This obviously assumes you are using MVVM!
Upvotes: 2