wpf 右键菜单比Winfrom好多了我是这么觉得,太好添加了,不用在拖控件了
就那canvas说吧
<Canvas Name="cView">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="添加图像" Click="ViewMenuItem_Click"/>
</ContextMenu>
</Canvas.ContextMenu>
</Canvas>
你要是不想写代码啊,更是容易去那个属性中去找ContextMenu更是不用写代码了
这个是后台的事件很容易的哦
if ((e.Source as MenuItem).Header.ToString() == "添加背景图片")
{
string filename = "";
ImageViewWidows win = new ImageViewWidows();
win.ShowDialog();
filename = win.filename;
//CreateBgImage(cView, filename);
}