Visual State Manager
Posted: 22 Apr 2021, 12:42
Hey, I try to use Visual State Manager. And I saw official Microsoft's tut: https://docs.microsoft.com/en-us/dotnet ... ew=net-5.0
And here is event declared MouseEnter="MouseEnterEventTexample" and after it fired in .cpp code I want go to te StateElement.. But I want to fire it automatically on the element it fired, no pass the UIElement like here:
1. Here is passed rect, but I dont want pass any elements becouse I dont know which element's event triggered. Can u help me?
2. Is it properly coded?
3. How the code setters?
That doesnt work. In normal triggers.setters that worked.
And here is event declared MouseEnter="MouseEnterEventTexample" and after it fired in .cpp code I want go to te StateElement.. But I want to fire it automatically on the element it fired, no pass the UIElement like here:
Code: Select all
VisualStateManager.GoToElementState(rect, "MouseEnter", true);2. Is it properly coded?
Code: Select all
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Grid>
<Path x:Name="Button" Data="M-12,0 L60,0 72,30 0,30 z" Stretch="Fill" Stroke="#FFBCBCC2" Fill="Black" Opacity="0.75" Width="350" Height="50" ForceCursor="True" StrokeThickness="2" UseLayoutRounding="True" SnapsToDevicePixels="True" Margin="4,-41,3.8,-2.2" />
<TextBlock x:Name="Label" Text="{TemplateBinding Content}" Margin="13.5,-20.4,13.165,15.12" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock>
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="MouseStates">
<VisualState x:Name="MouseEnterTest">
<VisualState.Setters>
<Setter Target="Button" Property="Stroke" Value="Yellow" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ControlTemplate>
</Setter.Value>
</Setter>Code: Select all
<VisualState.Setters>
<Setter Target="Button" Property="Stroke" Value="Yellow" />
</VisualState.Setters>