自定义一个toolbar,你希望像arcgis自带的Navigation那个
<esriToolkit:Navigation Map="{Binding ElementName=MyMap}"></esriToolkit:Navigation>
Map="{Binding ElementName=MyMap}"这种方式去实现控件绑定的话,
要使用到silverlight的DependencyProperty的这个东西
DependencyProperty 的使用方法具体可以查看http://www.cnblogs.com/yjmyzz/archive/2009/12/23/1630526.html
这个高人写的,
像自带的Navigation控件那样实现控件绑定,
propdp 在敲两下tab键,自动会出现
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty,value); }
}
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty,value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation,styling,binding,etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty",typeof(int),typeof(ownerclass),new UIPropertyMetadata(0));
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty",typeof(int),typeof(ownerclass),new UIPropertyMetadata(0));
DependencyProperty.Register("MyProperty",typeof(ESRI.ArcGIS.Client.Map),new UIPropertyMetadata(0));
关键是修改这里,通过查看msdn了解DependencyProperty.Register使用方法,
名称 | 说明 | |
---|---|---|
Register(String,Type,Type) | 使用指定的属性名称、属性类型和所有者类型注册依赖项属性。 | |
Register(String,PropertyMetadata) | 使用指定的属性名称、属性类型、所有者类型和属性元数据注册依赖项属性。 | |
Register(String,PropertyMetadata,ValidateValueCallback) | 使用指定的属性名称、属性类型、所有者类型、属性元数据和属性的值验证回调来注册依赖项属性。 |
很好理解 的,
DependencyProperty.Register("Map",typeof(ESRI.ArcGIS.Client.Map),typeof(toolbar),new PropertyMetadata(new ESRI.ArcGIS.Client.Map(),new PropertyChangedCallback(OnMapPropertyChanged)));
private static void OnMapPropertyChanged(DependencyObject d,DependencyPropertyChangedEventArgs e)
{
toolbar ctl = d as toolbar;
ESRI.ArcGIS.Client.Map map = d.GetValue(toolbar.MapProperty) as ESRI.ArcGIS.Client.Map;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。