我爲項目在菜單中顯示的方式進行了模板化,但由於未知原因,我無法在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