I added the code in the code behind, but I still get an error in the legenddialog.xaml indicating the ..........The property 'Map' was not found in type 'Control'
Still not sure if this is correct....
I get the following error..........The property 'Map' was not found in type LegendDialog
protected static readonly DependencyProperty MapProperty = DependencyProperty.Register("Map", typeof(Map), typeof(LegendDialog), new PropertyMetadata(OnMapPropertyChanged)); public Map Map { get { return (Map)this.GetValue(MapProperty); } set { this.SetValue(MapProperty, (DependencyObject)value); MessageBox.Show("in the GetValue(MapProperty"); } } private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { MessageBox.Show("in the OnMapPropertyChanged"); }
not sure what was needed in the private void PopulateLayerList()
<esri:Legend Map="{Binding ElementName=MyMap}"
<esri:Legend Map="{TemplateBinding Map}" .....
<local:LegendDialog x:Name="MyLegendDialog" Canvas.Left="430" Canvas.Top="200" Height="225" Width="218" Visibility="Collapsed" Map="{Binding ElementName=MyMap}" />
Hi Ann, One way to acheive this could be using Dependancy Property in your UserControl: #region Dependancy Properties protected static readonly DependencyProperty MapProperty= DependencyProperty.Register("Map", typeof(Map), typeof(YourUserControlName), new PropertyMetadata(OnMapPropertyChanged)); public Map Map { get { return (Map)this.GetValue(MapProperty); } set { this.SetValue(MapProperty, (DependencyObject)value); } } private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as YourUserControlName).PopulateLayerList(); } private void PopulateLayerList() { if (this.Map != null) { //populate your layer list here } } #endregion Then your UserControl declaration in xaml will be:[HTML]<local:WidgetControl x:Name="MyWidget" Map="{Binding ElementName=MyMap}"/>[/HTML]I haven't tested it your scenario and there might be a better approach, but it might be worth trying.Good Luck!
#region Dependancy Properties protected static readonly DependencyProperty MapProperty= DependencyProperty.Register("Map", typeof(Map), typeof(YourUserControlName), new PropertyMetadata(OnMapPropertyChanged)); public Map Map { get { return (Map)this.GetValue(MapProperty); } set { this.SetValue(MapProperty, (DependencyObject)value); } } private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as YourUserControlName).PopulateLayerList(); } private void PopulateLayerList() { if (this.Map != null) { //populate your layer list here } } #endregion
<local:WidgetControl x:Name="MyWidget" DataContext="{Binding ElementName=MyMap}"/>
<ComboBox x:Name="MyComboBox" ItemsSource="{Binding Layers}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding ID}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.