Search code examples
xamldevexpressdevexpress-wpf

How do I provide a custom data as a DataProvider for ImageTilesLayer on a mapControl in XAML file?


How do I provide a custom data as a DataProvider for ImageTilesLayer on a mapControl in XAML file?

I am new to WPF and DevExpress. I was trying a few examples given in the DevExpress documentation site.

Link: How to Load Image Tiles from Another Source

In the example, How to Load Image Tiles from Another Source given in their site, the DataProvider for a ImageTilesLayer is assigned in the code behind file. Is it possible to mention the same DataProvider in the XAML instead of the code behind file?


Solution

  • You can assign the ImageTilesLayer.DataProvider property in XAML as follows:

    <dxc:MapControl>
        <dxc:ImageTilesLayer>
            <dxc:ImageTilesLayer.DataProvider>
                <local:CustomMapDataProvider/>
            </dxc:ImageTilesLayer.DataProvider>
        </dxc:ImageTilesLayer>
    </dxc:MapControl>
    

    P.S.
    For more information about XAML properties syntax, see XAML Overview (WPF)-> Property Element Syntax MSDN article.
    For more information about custom types in XAML, see XAML and Custom Classes for WPF.