In my application, I actually use a button (not a toggle button) to show the print dialog. Is there a way to get a zoomed map in the print dialog?
I use the 'layerids' to limit the layers displayed in the legend. But I didn't find the similar thing in the legend in the printer style.
private void PrintBtn_Click(object sender, RoutedEventArgs e) { if (MapPrinterDialog.Visibility == System.Windows.Visibility.Collapsed) { MapPrinterDialog.Visibility = System.Windows.Visibility.Visible; mapPrinterWithDialog.IsActive = true; } else { MapPrinterDialog.Visibility = System.Windows.Visibility.Collapsed; mapPrinterWithDialog.IsActive = false; } }
<!--set the print dialog--> <controls:MapPrinterDialog x:Name="MapPrinterDialog" Background="White" Width="350" Height="400" Style="{StaticResource MyMapPrinterDialogStyle}" Visibility="Collapsed" > <controls:MapPrinter x:Name="mapPrinterWithDialog" Map="{Binding ElementName=MyMap}" Style="{StaticResource WithLegend}" Title="DIRT" PageChanged="mapPrinter_PageChanged" IsScaleFixed="True" Scale="2000000" /> <!--IsActive="{Binding ElementName=PrintBtn }"--> </controls:MapPrinterDialog> <controls:MapPrinterIndicator MapPrinter="{Binding ElementName=mapPrinter}" />
IsScaleFixed="True" Scale="2000000"
<!-- Legend --> <Border Background="{TemplateBinding Background}"> <StackPanel> <TextBlock Text="Legend" FontWeight="Bold" HorizontalAlignment="Center"/> <esri:Legend x:Name="PrintLegend" Map="{Binding ElementName=PrintMap}" LayerIDs="Visible Layers,,,"> <esri:Legend.Style> <Style TargetType="esri:Legend"> <Setter Property="LayerItemsMode" Value="Flat" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="esri:Legend"> <ItemsControl ItemsSource="{TemplateBinding LayerItemsSource}"> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Vertical"> <!--Layer Item--> <TextBlock Text="{Binding Label}" FontWeight="SemiBold"/> <!--Legend Items--> <ItemsControl ItemsSource="{Binding LegendItems}" > <ItemsControl.ItemTemplate> <DataTemplate > <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Template}" /> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ControlTemplate> </Setter.Value> </Setter> </Style> </esri:Legend.Style> </esri:Legend> </StackPanel> </Border>
But with the fixed scale, when I click the button to unfold the MapPrinterDialog, the print extent doesn't change.
This legend is located in the style 'WithLegend'. Then how should I call this legend in the code behind??
Legend printLegend; //this event used in print legend style to get access to the element in the style private void PrintLegend_Loaded(object sender, RoutedEventArgs e) { printLegend = sender as Legend; printLegend.LayerIDs.SetValue("MySelectionGraphicsLayer", legendIDcount); }
<!-- Map--> <Border BorderBrush="Black" BorderThickness="1"> <esri:Map x:Name="PrintMap" IsLogoVisible="False" controls:CloneMap.Map="{TemplateBinding Map}" controls:SurrogateBinder.OverviewMapPrinter="{Binding RelativeSource={RelativeSource TemplatedParent}}"> <controls:PrintOverviewLayer> <controls:PrintOverviewLayer.ExtentFillSymbol> <esri:SimpleFillSymbol BorderBrush="Red" BorderThickness="3" Fill="Transparent" /> </controls:PrintOverviewLayer.ExtentFillSymbol> </controls:PrintOverviewLayer> </esri:Map> </Border>
I see there is a big number in the red rectangle on the print dialog and it is the page number. I went through the map part in the template, but didn't find where I can modify to disable this big number....
<controls:PrintOverviewLayer TextSymbol="{x:Null}">
<controls:PrintOverviewLayer.ExtentFillSymbol>
<esri:SimpleFillSymbol BorderBrush="Red" BorderThickness="3" Fill="Transparent" />
</controls:PrintOverviewLayer.ExtentFillSymbol>
</controls:PrintOverviewLayer>
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="2" Grid.ColumnSpan="2" Text="{Binding Scale, RelativeSource={RelativeSource TemplatedParent}, StringFormat='1 : {0:F0} '}" />
Text="{Binding Scale, RelativeSource={RelativeSource TemplatedParent}, StringFormat='1 : {0:F0} '}"