<Grid x:Name="LayoutRoot"> <esri:Map x:Name="map_TestMap" WrapAround="True"> <esri:ArcGISTiledMapServiceLayer Url="http://services.arcgisonline.com:80/ArcGIS/rest/services/World_Street_Map/MapServer"/> </esri:Map> <sdk:TabControl x:Name="tc_1" HorizontalAlignment="Right" Width="300"> <sdk:TabItem x:Name="ti_1" Header="TabItem 1"> <!--<nestedTabControlControls:TestControl x:Name="test_4" VerticalAlignment="Top" Map="{Binding ElementName=map_TestMap}"/>--> <sdk:TabControl x:Name="tc_2"> <sdk:TabItem x:Name="ti_Nested1" Header="Nested TabItem 1"> <nestedTabControlControls:TestControl x:Name="test_1" VerticalAlignment="Top" Map="{Binding ElementName=map_TestMap}"/> </sdk:TabItem> <sdk:TabItem x:Name="ti_Nested2" Header="Nested TabItem 2"> <nestedTabControlControls:TestControl x:Name="test_2" VerticalAlignment="Top" Map="{Binding ElementName=map_TestMap}"/> </sdk:TabItem> </sdk:TabControl> </sdk:TabItem> <sdk:TabItem x:Name="ti_2" Header="TabItem 2"> <nestedTabControlControls:TestControl x:Name="test_3" VerticalAlignment="Top" Map="{Binding ElementName=map_TestMap}"/> </sdk:TabItem> </sdk:TabControl> </Grid>
using System.Windows; using System.Windows.Controls; using ESRI.ArcGIS.Client; namespace NestedTabControl.Controls { [TemplatePart(Name = TestControl.MapNameElementName, Type = typeof(TextBlock))] public class TestControl : Control { private const string MapNameElementName = "txt_Map"; public const string MapPropertyName = "Map"; public TestControl() { this.DefaultStyleKey = typeof(TestControl); } private TextBlock _txtMap; public static readonly DependencyProperty MapProperty = DependencyProperty.Register(MapPropertyName, typeof(Map), typeof(TestControl), new PropertyMetadata(OnMapPropertyChanged)); private static void OnMapPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as TestControl).OnMapPropertyChanged(e.NewValue, e.OldValue); } private void OnMapPropertyChanged(object newValue, object oldValue) { if (_txtMap != null) _txtMap.Text = ((Map)newValue).Name; } public override void OnApplyTemplate() { base.OnApplyTemplate(); _txtMap = GetTemplateChild(MapNameElementName) as TextBlock; } public Map Map { get { return (Map)GetValue(MapProperty); } set { SetValue(MapProperty, value); } } } }
Solved! Go to Solution.
Nope. I'm pretty confident it's an issue with the Map control though. I'm hoping someone from ESRI can shed some light on this.
<sdk:TabControl x:Name="tc_SidePanel" HorizontalAlignment="Right" Width="300"> <sdk:TabControl.Resources> <ContentControl x:Key="IShouldNotHaveToDoThis" Tag="{Binding ElementName=map_TestMap}"/> </sdk:TabControl.Resources>
<nestedTabControlControls:TestControl x:Name="test_5" VerticalAlignment="Top" Map="{Binding Tag, Source={StaticResource IShouldNotHaveToDoThis}}" Test="{Binding Text, ElementName=txt_TestValue}"/>
Did this ever work for you?
Nope. I'm pretty confident it's an issue with the Map control though. I'm hoping someone from ESRI can shed some light on this.
<sdk:TabControl x:Name="tc_SidePanel" HorizontalAlignment="Right" Width="300"> <sdk:TabControl.Resources> <ContentControl x:Key="IShouldNotHaveToDoThis" Tag="{Binding ElementName=map_TestMap}"/> </sdk:TabControl.Resources>
<nestedTabControlControls:TestControl x:Name="test_5" VerticalAlignment="Top" Map="{Binding Tag, Source={StaticResource IShouldNotHaveToDoThis}}" Test="{Binding Text, ElementName=txt_TestValue}"/>