第三种方法,还是使用微软的@H_419_15@Menu构造函数,不过是在@H_419_15@xaml界面中通过样式来使用它。不过笔者只在ArcGIS的中图形样式中使用成功了。其它的地方没有尝试,不过在SuperMap的feature应用理论上是可以成功。
Ⅰ菜单类
①
Xaml页面
<UserControl x:Class="TDWS.ClIEnt.UI.SuperMapUI.RegionContextMenu"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/Expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
>
<GrID x:name="LayoutRoot">
<Ellipse x:name="ellHot" Height="10" WIDth="10" Fill="Green" Opacity="0"></Ellipse>
</GrID>
</UserControl>
②
Xaml页面的CS文件
using System;
using System.Collections.Generic;
using System.linq;
using System.Net;
using System.windows;
using System.windows.Controls;
using System.windows.documents;
using System.windows.input;
using System.windows.Media;
using System.windows.Media.Animation;
using System.windows.Shapes;
using TDWS.ClIEnt.UI.query;
using Chaos.Controls.windows;
using TDWS.ClIEnt.UI.Edit;
namespace TDWS.ClIEnt.UI.SuperMapUI
{
public partial class RegionContextMenu : UserControl
{
public RegionContextMenu()
{
InitializeComponent();
OnPropertyChanged(this,new DependencyPropertyChangedEventArgs() { });
}
IDictionary<string,object> _ContextDataSource = null;
public static DependencyProperty _MenuDataSourceProperty = DependencyProperty.Register("ContextDataSource",
typeof(IDictionary<string,object>),
typeof(RegionContextMenu),
new PropertyMetadata(new PropertyChangedCallback(OnPropertyChanged)));
public IDictionary<string,object> ContextDataSource
{
get { return _ContextDataSource; }
set { _ContextDataSource = value; }
}
private static voID OnPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != null)
{
RegionContextMenu dd = new RegionContextMenu();
d = dd;
dd.ContextDataSource = e.NewValue as IDictionary<string,object>;
dd.BindContextMenu();
}
}
private voID BindContextMenu()
{
ContextMenu menu = new ContextMenu();
MenuItem regioninfo = new MenuItem();
regioninfo.header = "人口基本信息";
regioninfo.Click += new RoutedEventHandler(regioninfo_Click);
menu.Items.Add(regioninfo);
ContextMenuService.SetContextMenu(ellHot,menu);
}
//人口基本信息
voID regioninfo_Click(object sender,RoutedEventArgs e)
{
if (this.ContextDataSource.ContainsKey("Adcd"))
{
RegionBaseinformationUI baseInfo = new RegionBaseinformationUI(this.ContextDataSource["Adcd"].ToString());
WindosEx.ShowDialog("人口基本信息",700,500,baseInfo);
}
}
}
}
Ⅱ该右键菜单的使用,它是作为一种样式传该
@H_419_15@<!--站点右键菜单样式@H_419_15@-->
@H_419_15@ <esri:MarkerSymbol x:Key="SiteContextMenuSymbol" OffsetX="10" OffsetY="10">
@H_419_15@ <esri:MarkerSymbol.ControlTemplate>
@H_419_15@ <ControlTemplate>
@H_419_15@ <my:RegionContextMenu ContextDataSource="{Binding Attributes}"></my:RegionContextMenu>
@H_419_15@ </ControlTemplate>
@H_419_15@ </esri:MarkerSymbol.ControlTemplate>
@H_419_15@ </esri:MarkerSymbol>
@H_419_15@<esri:SimpleRenderer x:Key="SiteContextMenuRenderer" Symbol="{StaticResource SiteContextMenuSymbol}"></esri:SimpleRenderer>
总结以上是内存溢出为你收集整理的Silverlight 4的是鼠标右键菜单的实现(三)全部内容,希望文章能够帮你解决Silverlight 4的是鼠标右键菜单的实现(三)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)