BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Visual State Manager

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:
VisualStateManager.GoToElementState(rect, "MouseEnter", true);
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?
<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>
3. How the code setters?
<VisualState.Setters>
	<Setter Target="Button" Property="Stroke" Value="Yellow" />
</VisualState.Setters>
That doesnt work. In normal triggers.setters that worked.

Tags:
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Visual State Manager

22 Apr 2021, 18:26

And why does animations dont work...
<Grid>
                        <Path x:Name="Button" Data="M0,0 L60,0 70,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">
                        </Path>
                        <TextBlock x:Name="Label" Text="{TemplateBinding Content}" Margin="161,91.8,161.042,91.621" HorizontalAlignment="Center" VerticalAlignment="Center" ></TextBlock>
                        <Path x:Name="Button_Glow" Data="M0,0 L60,0 70,30 0,30 z" Stretch="Fill" Stroke="{x:Null}" Fill="#FFFDFF00" Opacity="0.285" Width="Auto" Height="Auto" ForceCursor="True" StrokeThickness="2" UseLayoutRounding="True" SnapsToDevicePixels="True" Margin="145,86,137.042,74.421">
                            <Path.Effect>
                                <BlurEffect Radius="50"/>
                            </Path.Effect>
                        </Path>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="TabStates">
                                <VisualState x:Name="TabFocused">
                                    <Storyboard RepeatBehavior="Forever" AutoReverse="True">
                                        <DoubleAnimation  Storyboard.TargetName="Button_Glow" Storyboard.TargetProperty="Opacity" From="0.0" To="0.22" Duration="0:0:0.8"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="TabNormal">
                                    <VisualState.Setters>

                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Grid>
Help :/
Nothing works, from source I call
Noesis::Symbol symbolFocused("TabFocused");
	Noesis::Symbol symbolNormal("TabNormal");

	VisualStateManager::GoToState(mainMenuTabs[index].GetButton(), symbolFocused, true);
 
BartekW
Topic Author
Posts: 53
Joined: 24 Mar 2021, 14:33

Re: Visual State Manager

25 Apr 2021, 22:54

Ok for those who will have the same issues. For me on OnInitialized() manager doesnt work, I setted it manaully in .xaml. Topic can be closed.
 
User avatar
jsantos
Site Admin
Posts: 3139
Joined: 20 Jan 2012, 17:18
Contact:

Re: Visual State Manager

28 Apr 2021, 11:23

Thank you! Closing this.

Who is online

Users browsing this forum: No registered users and 3 guests