Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 318647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:35:19+00:00 2026-05-12T08:35:19+00:00

I have a WPF Window with a Canvas that is used to show a

  • 0

I have a WPF Window with a Canvas that is used to show a terrain map. I would like to place symbols on this map according to an IEnumerable<MapSymbolDefinition> where MapSymbolDefinition is defined as follows:

public class MapSymbolDefinition
{
  string SymbolFileName { get; set; }
  int XLocation { get; set; }
  int YLocation { get; set; }
}

All symbols are stored in the Symbols folder of my project, so the path to any symbol would be [ProjectFolder]/Symbols/SymbolFileName.bmp.

Any thoughts on how I can set this up so I don’t have to populate a bunch of Image objects manually in the code-behind?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:35:19+00:00Added an answer on May 12, 2026 at 8:35 am

    Use an ItemsControl with customized ItemsPanel, ItemContainerStyle and ItemTemplate:

    <ItemsControl ItemsSource="{Binding MapSymbols}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas/>
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemContainerStyle>
            <Style>
                <Setter Property="Canvas.Top" Value="{Binding YLocation}"/>
                <Setter Property="Canvas.Left" Value="{Binding XLocation}"/>
            </Style>
        </ItemsControl.ItemContainerStyle>
        <ItemsControl.ItemTemplate>
            <DataTemplate DataType="{x:Type local:MapSymbolDefinition}">
                <Image Source="{Binding SymbolFileName, Converter={StaticResource ImageNameConverter}}"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    Update after comments: You can define an ItemTemplate to provide the visual tree for each item in the collection. In this case I used a converter to convert the SymbolFileName property to an image, but you could equally define a separate property on your MapSymbolDefinition class that yields the full path. The latter approach is more in line with MVVM best practices.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am NEW to WPF. I have the following XAML code: </Window> ... <Canvas>
So if I have a WPF window, would moving another window over the WPF
At the moment I have a DocumentViewer in a WPF window that displays an
I have a small problem, when I open a new window in WPF like
I have WPF window that uses a dockpanel and the menu control. I have
Suppose you have WPF Window composed of many elements that are using DataTemplates /
I have a Window where I have put a Frame. I would like to
Everyone, I have a WPF app that has a canvas that I have wrapped
I have a WPF window with a TreeView that contains a checkbox at each
I have a simple WPF Window with a Canvas on it and the Canvas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.