【发布时间】:2015-08-03 14:48:20
【问题描述】:
有人可以帮我,为本教程的每个 MenuItem 添加图像:
http://www.codeproject.com/Articles/522343/A-Pie-Menu-for-WPF
我不知道该怎么做。
【问题讨论】:
有人可以帮我,为本教程的每个 MenuItem 添加图像:
http://www.codeproject.com/Articles/522343/A-Pie-Menu-for-WPF
我不知道该怎么做。
【问题讨论】:
试试这个:
</MyNamespace:PieMenu.BitmapEffect>
<Image Source="Items\1.png" Width="50" Height="50"/>
<Image Source="Items\2.png" Width="50" Height="50"/>
<Image Source="Items\3.png" Width="50" Height="50"/>
<Image Source="Items\4.png" Width="50" Height="50"/>
<Image Source="Items\5.png" Width="50" Height="50"/>
</MyNamespace:PieMenu>
【讨论】:
我有类似的问题。我最终玩了 PieMenuItem 的 header 属性。这样的事情会奏效。
if (menu_item.Header as FrameworkElement != null)
{
FrameworkElement header = (FrameworkElement)menu_item.Header;
// Create the visual brush based on the UserControl
VisualBrush headerVisualBrush = new VisualBrush(header);
headerVisualBrush.Stretch = Stretch.Uniform;
// Draw using the visual brush in the rect
double contentSize = distance / 2;
drawingContext.DrawRectangle(headerVisualBrush, null, new Rect(center.X - contentSize / 2.0, center.Y - contentSize / 2.0, contentSize, contentSize));
}
else if (menu_item.Header as String != null)
{
}
【讨论】: