使用视觉触发器时 UWP Hamburger 导航菜单错误 - XAML
UWP Hamburger navigation menu error when using visual triggers - XAML
我正在使用可视触发器为 UWP 创建汉堡包导航 UI,但出现此错误。
"An animation is trying to modify an object named 'HamburgerButtonMobile', but no such object can be found in the Page."
这是我的代码
<VisualState.Setters>
<Setter Target="HamburgerButtonMobile.Visibility" Value="Collapsed" />
</VisualState.Setters>
<Pivot x:Name="MoviesPivot" Title="MOVIES">
<Pivot.TitleTemplate>
<DataTemplate>
<RelativePanel>
<TextBlock Text="{Binding}" FontSize="72" Foreground="#FF21B255" FontWeight="Light" RelativePanel.AlignRightWithPanel="True" x:Name="titleName"/>
<Button x:Name="HamburgerButtonMobile" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent" Click="HamburgerButtonMobile_Click" RelativePanel.LeftOf="titleName" RelativePanel.AlignVerticalCenterWithPanel="True" />
</RelativePanel>
</DataTemplate>
</Pivot.TitleTemplate>
您的 Visual Trigger 看不到该项目的原因是您尝试访问的项目位于 DataTemplate
中。它还“不存在”
我认为 您想要做的是将视觉触发器添加到RelativePanel
。
老实说,如果没有看到更多代码,很难说。
<RelativePanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="BlahNameState">
<VisualState.Setters>
<Setter Target="HamburgerButtonMobile.Visibility" Value="Collapsed" />
</VisualState.Setters>
我正在使用可视触发器为 UWP 创建汉堡包导航 UI,但出现此错误。 "An animation is trying to modify an object named 'HamburgerButtonMobile', but no such object can be found in the Page." 这是我的代码
<VisualState.Setters>
<Setter Target="HamburgerButtonMobile.Visibility" Value="Collapsed" />
</VisualState.Setters>
<Pivot x:Name="MoviesPivot" Title="MOVIES">
<Pivot.TitleTemplate>
<DataTemplate>
<RelativePanel>
<TextBlock Text="{Binding}" FontSize="72" Foreground="#FF21B255" FontWeight="Light" RelativePanel.AlignRightWithPanel="True" x:Name="titleName"/>
<Button x:Name="HamburgerButtonMobile" FontFamily="Segoe MDL2 Assets" Content="" Width="50" Height="50" Background="Transparent" Click="HamburgerButtonMobile_Click" RelativePanel.LeftOf="titleName" RelativePanel.AlignVerticalCenterWithPanel="True" />
</RelativePanel>
</DataTemplate>
</Pivot.TitleTemplate>
您的 Visual Trigger 看不到该项目的原因是您尝试访问的项目位于 DataTemplate
中。它还“不存在”
我认为 您想要做的是将视觉触发器添加到RelativePanel
。
老实说,如果没有看到更多代码,很难说。
<RelativePanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="BlahNameState">
<VisualState.Setters>
<Setter Target="HamburgerButtonMobile.Visibility" Value="Collapsed" />
</VisualState.Setters>