C# WPF-自定义饼图菜单-菜单项图像
是否有人可以帮助我向本教程的每个菜单项添加图像: 我不知道怎么做。试试这个:C# WPF-自定义饼图菜单-菜单项图像,c#,wpf,menu,C#,Wpf,Menu,是否有人可以帮助我向本教程的每个菜单项添加图像: 我不知道怎么做。试试这个: </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" He
</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)
{
}
不不幸的是,这不起作用。编译器说,“BitmapEffect”属性不支持“Image”。