Original User: erpiant
Good Morning Dominique!
I have successfully implemented printing the map with legend using your example and setting the 'WithLegend' on the 'Style' attribute on the MapPrinterDialog defined on my 'MainPage.xaml':
<userControls:WindowPanel x:Name="PrintDialogPanel" ContentTitle="PDF Printing" Collapsible="False" Closable="True" Minimized="False" Visibility="Collapsed" Width="470" Height="600" >
<controls:MapPrinterDialog Height="410" Width="340" >
<controls:MapPrinter x:Name="mapPrinter" Map="{Binding ElementName=MyMap}" Style="{StaticResource WithLegend}"/>
</controls:MapPrinterDialog>
</userControls:WindowPanel>
I defined the 'WithLegend' template in the UserResources section of the MainPage.xaml.
Also, in the code-behind page, I return the results of a query to a datagrid ('SchoolsDataGrid') located on the MainPage.xaml:
<slData:DataGrid x:Name="SchoolsDataGrid" AutoGenerateColumns="False" HeadersVisibility="All"
Background="White">
<slData:DataGrid.Columns>
<slData:DataGridTextColumn CanUserSort="False" SortMemberPath="NAME" Binding="{Binding Attributes[NAME]}" Header="School Name"/>
<slData:DataGridTextColumn CanUserSort="False" Binding="{Binding Attributes[PHONE]}" Header="School Phone"/>
<slData:DataGridTextColumn CanUserSort="False" Binding="{Binding Attributes[TYPE]}" Header="Type"/>
<!--<slData:DataGridTextColumn CanUserSort="False" Binding="{Binding Attributes[ADDRESS]}" Header="Address"/>-->
</slData:DataGrid.Columns>
</slData:DataGrid>
Is it possible to add a datagrid to the 'WithLegend' template? And if so, how? I was attempting to add it between the map and the text printout at the bottom of the map printout page but I am unsure of the syntax to use to bind the text column data to the templated parent so I used ??? as a placeholder for the correct syntax:
<!--Third Row of Grid-->
<StackPanel Orientation="Vertical" Background="{TemplateBinding Background}" Grid.Row="2">
<slData:DataGrid>
<slData:DataGrid.Columns>
<slData:DataGridTextColumn ??? />
</slData:DataGrid.Columns>
</slData:DataGrid>
</StackPanel>
<!--Fourth Row of Grid-->
<!-- Footer -->
<Grid Background="{TemplateBinding Background}" Grid.Row="3" Grid.ColumnSpan="2">
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center"
Text="{Binding Now, RelativeSource={RelativeSource TemplatedParent}, StringFormat='Printed {0:d} '}" />
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="2" Grid.ColumnSpan="2"
Text="{Binding Scale, RelativeSource={RelativeSource TemplatedParent}, StringFormat='1 : {0:F0} '}" />
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, StringFormat='Page {0} '}" />
<TextBlock Text="{Binding PageCount, RelativeSource={RelativeSource TemplatedParent}, StringFormat='/ {0}'}" />
</StackPanel>
</Grid>
</Grid>
What is the correct syntax to use to bind the printout datagrid to the web map datagrid so that I may printout a map with legend plus a datagrid in Silverlight. I know I can set the 'Style' attribute only once on the MapPrinterDialog control. None of the 'Style' template options provide a map with both a legend and a datagrid on the printout. I thought the easiest way was to add code for a datagrid to the 'WithLegend' template.
Please explain or provide example.
Thanks, Liz