在项目中我有.xaml如下:
<UserControl>
<UserControl.Resources>
<Style TargetType="ToolBarItem" x:Key = "LayerToolBar">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<MenuToggleButton x:Name="foregroundbutton">
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<ToolBarItem Style="{DynamicResource LayerToolBar}"/>
</UserControl>
问题是我如何访问代码隐藏文件中的“foregroundbutton”