Hi,
My application having a legend control which displays the layer information for the map. I have a child window where I want to put the legend information. I am able to extract the legend information from the main xaml page to the child window but I am unable to put it to the child window.
My mainpage xaml code is
<Button x:Name="btnPrint" Height="30" Width="30" Click="btnPrint_Click" Canvas.Left="573" Canvas.Top="14">
<Image Source="Images/Printer.png" Canvas.Left="555" Canvas.Top="6" />
</Button>
Mainpagexaml.cs code is
MapPrintView printView = new MapPrintView();
printView.DataContext = viewModel;
printView.BuildMap();
//If there are layers to build a legend for, build the legend.
if (viewModel.MapGraphics != null && viewModel.MapGraphics.Count > 0)
{
printView.CreateLegend();
}
My child widow code where I want to put my legend information
MapPrintView.xaml
<esriToolkit:Legend Map="{Binding ElementName=edmsMap}" x:Name="printMapLegend" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,53,6,6" Grid.Row="3" Grid.Column="2">
<esriToolkit:Legend.MapLayerTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox x:Name="ColorTextBox" Width="50" Height="50"
Background="{Binding Label}"/>
<CheckBox x:Name="legendSelectionCheckBox" Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}"
>
</CheckBox>
<Button x:Name="deleteLayerButton" Width="25" Height="25" Tag="{Binding Label}" >
<Image Source="Images/delete.png" ToolTipService.ToolTip="Remove Program Type"/>
</Button>
<Button x:Name="showResultButton" Width="25" Height="25" Tag="{Binding Label}" >
<Image Source="Images/reports-icon.png" ToolTipService.ToolTip="Show Program Type Results"/>
</Button>
<Button x:Name="selectGraphicResults" Width="25" Height="25" Tag="{Binding Label}" >
<Image Source="Images/query_rectangle.png" ToolTipService.ToolTip="Select an area on the Map to display its results"/>
</Button>
</StackPanel>
</DataTemplate>
</esriToolkit:Legend.MapLayerTemplate>
<esriToolkit:Legend.LayerTemplate>
<DataTemplate>
<CheckBox x:Name="legendSelectionCheckBox" Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}"
>
</CheckBox>
</DataTemplate>
</esriToolkit:Legend.LayerTemplate>
</esriToolkit:Legend>
MapPrintView.xaml.cs
public void CreateLegend()
{
printMapLegend = viewModel.CreateLegendInformation();
}
public Legend CreateLegendInformation()
{
return mapLegend;
}
I am getting the legend information in this last line code of "mapLegend" but unable to put it to the child window. Can anybody please help me on this.
Thanks in advance.
~Saurabh.