Skip to main content

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

MapPrintOptions Class

Contains map print options.

Namespace: DevExpress.Xpf.Map

Assembly: DevExpress.Xpf.Map.v25.1.dll

NuGet Package: DevExpress.Wpf.Map

#Declaration

public class MapPrintOptions :
    MapDependencyObject

The following members return MapPrintOptions objects:

#Remarks

Export also depends on these settings. To see examples, refer to the Map Control: Printing and Exporting section.

#Example

To print a map, use one of the following methods.

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:dxp="http://schemas.devexpress.com/winfx/2008/xaml/printing"
        xmlns:dxlc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
        xmlns:dxm="http://schemas.devexpress.com/winfx/2008/xaml/map"  
        xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" 
        xmlns:local="clr-namespace:PrintingExporting"
        x:Class="PrintingExporting.MainWindow"
        Title="MainWindow" Height="600" Width="800">

    <Window.Resources>
        <ObjectDataProvider x:Key="PrintSizeValues" MethodName="GetValues"
                            ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="dxm:MapPrintSizeMode" />
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
        <ObjectDataProvider x:Key="PrintMethodValues" MethodName="GetValues"
                            ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="local:PrintMetod"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>

    <Grid>
        <dxlc:LayoutControl>
            <dxlc:LayoutGroup Orientation="Vertical">
                <dxlc:LayoutItem HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <dxm:MapControl Name="mapControl">
                        <dxm:MapControl.PrintOptions>
                            <dxm:MapPrintOptions SizeMode="{Binding SelectedItem, ElementName=cbPrintingSize}"/>
                        </dxm:MapControl.PrintOptions>
                        <dxm:ImageTilesLayer>
                            <dxm:ImageTilesLayer.DataProvider>
                                <dxm:BingMapDataProvider BingKey="Your Bing Key"/>
                            </dxm:ImageTilesLayer.DataProvider>
                        </dxm:ImageTilesLayer>
                    </dxm:MapControl>
                </dxlc:LayoutItem>
                <dxlc:LayoutGroup>
                    <dxlc:LayoutItem Label="Printing Size" AddColonToLabel="True">
                        <ComboBox x:Name="cbPrintingSize" SelectedIndex="0"
                                  ItemsSource="{Binding Source={StaticResource PrintSizeValues}}"/>
                    </dxlc:LayoutItem>
                    <dxlc:LayoutItem Label="Print Method" AddColonToLabel="True">
                        <ComboBox x:Name="cbPrintingMethod" SelectedIndex="0"
                                  ItemsSource="{Binding Source={StaticResource PrintMethodValues}}"/>
                    </dxlc:LayoutItem>
                    <dxlc:LayoutItem Width="100">
                        <Button Content="Print" Click="Button_Click"/>
                    </dxlc:LayoutItem>
                </dxlc:LayoutGroup>
            </dxlc:LayoutGroup>
        </dxlc:LayoutControl>
    </Grid>
</Window>
using System.Windows;

namespace PrintingExporting {
    public enum PrintMetod { RibbonPreview, RibbonPreviewDialog, Preview, PreviewDialog };

    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e) {
            #region #PrintMethods
            switch ((PrintMetod)cbPrintingMethod.SelectedItem) {
                case (PrintMetod.RibbonPreview):
                    mapControl.ShowRibbonPrintPreview(this);
                    break;
                case (PrintMetod.RibbonPreviewDialog):
                    mapControl.ShowRibbonPrintPreviewDialog(this);
                    break;
                case (PrintMetod.Preview):
                    mapControl.ShowPrintPreview(this);
                    break;
                case (PrintMetod.PreviewDialog):
                    mapControl.ShowPrintPreviewDialog(this);
                    break;
            }
            #endregion #PrintMethods
        }
    }
}
See Also