我为项目在菜单中显示的方式进行了模板化,但由于未知原因,我无法在MenuItem中显示整个文本。这是问题的一个屏幕截图: alt text http://img203.imageshack.us/img203/4513/capturexz.pngWPF MenuItem标题文本部分隐藏
下面是我用模板它的标记代码:
<ItemsPanelTemplate x:Key="SideBarItemsPanelTemplate">
<StackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
<DataTemplate x:Key="SideBarItemTemplate">
<MenuItem Command="{Binding}" Header="{Binding Text}" Background="AliceBlue">
<MenuItem.Icon>
<Image Width="16" Height="16" Source="{Binding Image}"/>
</MenuItem.Icon>
</MenuItem>
</DataTemplate>
<Style x:Key="SideBarStyle" TargetType="{x:Type Menu}">
<Setter Property="ItemTemplate" Value="{StaticResource SideBarItemTemplate}"/>
<Setter Property="ItemsPanel" Value="{StaticResource SideBarItemsPanelTemplate}"/>
<Setter Property="Background" Value="White"/>
</Style>
,并显示它:
<Menu ItemsSource="{Binding Commands}" Style="{StaticResource SideBarStyle}"/>
我搜索了很多,但没有什么帮助解决这个问题。希望我会在这里找到一些帮助。
谢谢。
你可以尝试宽度为菜单项 – Ragunathan 2010-07-28 10:09:20
它显示了我更多的文字一点点,但,这只是因为项目更长。右侧仍然有一种裁剪方式。 – Ucodia 2010-07-28 10:18:31
尝试宽度到菜单 – Ragunathan 2010-07-28 11:42:33