CheckGlyph
FontIconをCollapsed
に隠すようにToggleMenuFlyoutItem styles and templatesを更新し、必要に応じてテキストコードを更新することができます。
<Style x:Key="ToggleMenuFlyoutItemStyle1" TargetType="ToggleMenuFlyoutItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleMenuFlyoutItem">
<Grid x:Name="LayoutRoot" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
<VisualStateManager.VisualStateGroups>
...
</VisualStateManager.VisualStateGroups>
<Grid x:Name="AnimationRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<FontIcon x:Name="CheckGlyph" Visibility="Collapsed" Foreground="{ThemeResource ToggleMenuFlyoutItemCheckGlyphForeground}" FontSize="16" FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="" Margin="0,0,12,0" Opacity="0" Width="16"/>
<TextBlock x:Name="TextBlock" Grid.Column="1" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Text="{TemplateBinding Text}" TextTrimming="Clip" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ToggleMenuFlyoutItem Text="Sales Tax Exempt" Click="btnTaxExempt_Click" Style="{StaticResource ToggleMenuFlyoutItemStyle1}" ></ToggleMenuFlyoutItem>
コードの後ろ
XAML:たとえば、あなたがMenuFlyout
を使用していない場合
private void btnTaxExempt_Click(object sender, RoutedEventArgs e)
{
ToggleMenuFlyoutItem current = sender as ToggleMenuFlyoutItem;
if(current.IsChecked)
{
current.Text = "Tax Exempt On";
}
else if(!current.IsChecked)
{
current.Text = "Tax Exempt Off";
}
}
ToggleMenuFlyoutItem
は、MenuFlyout
内部で使用する必要があり、あなたの代わりにToggleSwitch
を使用することを検討することができます。 ToggleSwitch
は簡単に設定できますOnContent
とOffContent
です。