0
我旁邊用戶控件:訪問setter屬性
<UserControl
x:Class="Test.Views.NavigationMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:RTUforWindows8.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<UserControl.Resources>
<Style x:Key="HomeAppBarButtonStyle" TargetType="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId" Value="HomeAppBarButton"/>
<Setter Property="AutomationProperties.Name" Value="ewffgwefwfwefwefwe"/>
<Setter Property="Content" Value=""/>
</Style>
</UserControl.Resources>
<StackPanel Orientation="Horizontal">
<Button
Style="{StaticResource HomeAppBarButtonStyle}" />
<Button
Style="{StaticResource AppBarButtonStyle}" />
</StackPanel>
而且在我的代碼我想改變:
<Setter Property="AutomationProperties.Name" Value="ewffgwefwfwefwefwe"/>
價值的東西,我做的:
NavigationMenu NM = new NavigationMenu();
var style = (NM.Resources["HomeAppBarButtonStyle"] as Style).Setters[1];
而不能弄清楚如何輸入set th是價值嗎?
這怎麼可能應該是這樣的: