【发布时间】:2021-10-06 11:37:28
【问题描述】:
我有一个 MenuItem,在这个 MenuItem 中我添加了一个 ItemSource,以便这个 menuItem 的项目是从一个 Observable 集合中创建的。我的 MenuItem 看起来像这样:
<MenuItem Foreground="Black"
FontFamily="{Binding ElementName=wpfAudit, Path=FontFamily}"
FontSize="{Binding ElementName=wpfAudit, Path=FontSize}"
FontWeight="{Binding ElementName=wpfAudit, Path=FontWeight}"
Header="Artikellabel Drucker"
ItemsSource="{Binding ocArtikellabeldrucker, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
</MenuItem>
现在我想编辑使用 ItemSource 创建的项目的 MenuItem.Icon。
我尝试的是这样的:
<MenuItem.Resources>
<RadioButton x:Key="RadioButtonResource" x:Shared="false" HorizontalAlignment="Center"
GroupName="MenuItemRadio" IsHitTestVisible="False" IsChecked="{Binding IstDrucker}" Style="{StaticResource {x:Type RadioButton}}"/>
</MenuItem.Resources>
但是这确实有效。那么我怎样才能让它发挥作用呢?也许使用 ControlTemplate ?
【问题讨论】: