我有主要的XAML页面包括两个框架:工具栏和内容。我也有几个不同的页面为这个框架。我使用命令栏到工具栏框架。如何通过AppBarButton单击事件从Frame更改Frame(例如在主页面中的TaskerToolbar)?或者如何将单击事件从TaskerToolbar发送到MainPage.xaml。谢谢你的帮助。
MainPage.xaml:
<Grid>
<Grid.RowDefinitions>
<!-- toolbar-->
<RowDefinition Height="110"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border CornerRadius="0,0,0,10" BorderThickness="0,0,0,5">
<Border.BorderBrush>
<LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1" Opacity="0.02">
<GradientStop Color="Gray" Offset="0"/>
<GradientStop Color="Black" Offset=".03"/>
<GradientStop Color="Black" Offset=".98"/>
<GradientStop Color="Gray" Offset="1"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Border CornerRadius="0,0,0,10" BorderBrush="#D4D4D4" BorderThickness="1,0,0,1">
<!-- toolbar frame -->
<Grid Grid.Row="0" Background="#F3F3F3">
<Frame x:Name="toolbarFrame"/>
</Grid>
</Border>
</Border>
<!-- content frame -->
<Grid Grid.Row="1">
<Frame x:Name="contentFrame"/>
</Grid>
</Grid>
MainPage.xaml.cs:
public MainChromeWindowView()
{
this.InitializeComponent();
toolbarFrame.Navigate(typeof(TaskerToolbar), null);
contentFrame.Navigate(typeof(SingleAView), null);
}
TaskerToolbar(和其他工具栏):
<Grid>
<CommandBar Style="{StaticResource OpenDownCommandBar}" HorizontalAlignment="Left" IsOpen="False" DefaultLabelPosition="Collapsed" Margin="0,15,0,0">
<AppBarButton Style="{StaticResource ImageAppBarButtonStyle}" LabelPosition="Default" Label="Recorder">
<AppBarButton.Content>
<Image>
<Image.Source>
<SvgImageSource UriSource="/Assets/icons/icon1.svg"/>
</Image.Source>
</Image>
</AppBarButton.Content>
</AppBarButton>
<AppBarButton Style="{StaticResource ImageAppBarButtonStyle}" LabelPosition="Default" Label="Configuration">
<AppBarButton.Content>
<Image>
<Image.Source>
<SvgImageSource UriSource="/Assets/icons/icon2.svg"/>
</Image.Source>
</Image>
</AppBarButton.Content>
</AppBarButton>
</CommandBar>
</Grid>
1条答案
按热度按时间kninwzqo1#
您可以将事件添加到
Page
类:TaskerToobar.xaml
TaskerToolbar.xaml.cs
订阅/取消订阅如下: