C# 更改AppBar';s菜单文本
我有下面的AppBarC# 更改AppBar';s菜单文本,c#,windows-8,microsoft-metro,C#,Windows 8,Microsoft Metro,我有下面的AppBar <Page.BottomAppBar> <AppBar x:Name="bottomAppBar" Padding="10,0,10,0"> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <Button x:Name="switchMeasu
<Page.BottomAppBar>
<AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
<Grid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="switchMeasurementMode" AutomationProperties.Name = "Breath rate" Style="{StaticResource AppBarButtonStyle}" Click="switchMeasurementMode_Click" />
</StackPanel>
</Grid>
</AppBar>
</Page.BottomAppBar>
但是按钮文本没有改变。有什么我遗漏的吗?按钮是一个内容控件。您可以设置内容属性来更改内容
this.switchMeasurementMode.Content= "111";
Name属性是为按钮设置编程“句柄”的方式。使用代码编辑器中的名称修改控件。在您的情况下,您正在更改名称,这意味着您失去了这样说的能力。switchMeasurementMode
仅供参考,内容可以不仅仅是文本。大多数XAML元素都可以作为内容添加。该按钮是一个内容控件。您可以设置内容属性来更改内容
this.switchMeasurementMode.Content= "111";
Name属性是为按钮设置编程“句柄”的方式。使用代码编辑器中的名称修改控件。在您的情况下,您正在更改名称,这意味着您失去了这样说的能力。switchMeasurementMode
仅供参考,内容可以不仅仅是文本。大多数XAML元素都可以作为内容添加。如果在Windows 8 C#项目中使用AppBar的默认样式,则必须更改附加属性AutomationProperties。在XAML中,使用以下两种方法之一更改名称: AutomationProperties.Name=“新名称” 或在代码中使用: SetValue(AutomationProperties.NameProperty,“新值”)
或
SetName(按钮,“新值”)
如果在Windows 8 C#项目中使用AppBar的默认样式,则必须使用以下方法在XAML中更改附加属性AutomationProperties.Name: AutomationProperties.Name=“新名称” 或在代码中使用: SetValue(AutomationProperties.NameProperty,“新值”)
或
SetName(按钮,“新值”)
太好了<代码>AutomationProperties.SetName(this.switchMeasurementMode,“111”)代码>适合我。太棒了<代码>AutomationProperties.SetName(this.switchMeasurementMode,“111”)代码>适合我。