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 8690103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:49:53+00:00 2026-06-12T23:49:53+00:00

Here is what I want to do: I have a List<myCustomType> . Now I

  • 0

Here is what I want to do: I have a List<myCustomType>. Now I want to display that list on a canvas (or any other container for that matter). Every property from myCustomType (a few strings, an image, a list of strings) has a designed control one the canvas. Basically I want to bind each control on my canvas to one property on myCustomType. Then I want to have buttons on the canvas that allow me to cycle through the List<myCustomType> and updates all controls at the same time so that all controls always show the contents of a single list item.

I have been looking around, but couldn’t find anything that I could use as a starting point.

Is that easily achievable? Or do I have to code that from scratch?

  • 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-06-12T23:49:54+00:00Added an answer on June 12, 2026 at 11:49 pm

    Here is an example using MVVM.

    My Customer model is very simple and looks like this:

    public class Customer
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }
    

    Next we need a ViewModel which the MainWindow of the application will be bound to. It holds the Customers and has the methods for moving between the Customers with buttons. The CollectionView type supports current item tracking and is I suppose something like WinForms’s BindingSource:

    public class MyViewModel
    {
        public ICollectionView Customers { get; set; }
    
        public void MoveSelectionLeft()
        {
            Customers.MoveCurrentToPrevious();
        }
    
        public void MoveSelectionRight()
        {
            Customers.MoveCurrentToNext();
        }
    
        public MyViewModel()
        {
            Customers = new CollectionViewSource
                {
                    Source = new[]
                        {
                            new Customer {Name = "John", Age = 25},
                            new Customer {Name = "Jane", Age = 27},
                            new Customer {Name = "Dawn", Age = 31}
                        }
                }.View;
        }
    }
    

    Next we have the View. I am using Caliburn Micro to simplify hooking up actions to the buttons. Simply download it and add a reference to Caliburn.Micro.dll to your project:

    <Window x:Class="WpfApplication.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:cal="http://www.caliburnproject.org" Title="MainWindow" Height="400" Width="400">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
    
        <ListBox Grid.RowSpan="2" ItemsSource="{Binding Customers}" DisplayMemberPath="Name"/>
    
        <DockPanel Grid.Column="1" LastChildFill="False">
            <Button DockPanel.Dock="Left" Content="&lt;"
                        cal:Message.Attach="[Event Click] = [MoveSelectionLeft]"/>
            <Button DockPanel.Dock="Right" Content="&gt;"
                        cal:Message.Attach="[Event Click] = [MoveSelectionRight]"/>
        </DockPanel>
    
        <StackPanel Grid.Row="1" Grid.Column="1">
            <DockPanel>
                <TextBlock MinWidth="50" Text="Name" Margin="0,0,5,0"/>
                <TextBox Text="{Binding Customers/Name}"/>
            </DockPanel>
            <DockPanel>
                <TextBlock MinWidth="50" Text="Age" Margin="0,0,5,0"/>
                <TextBox Text="{Binding Customers/Age}"/>
            </DockPanel>
        </StackPanel>
    </Grid>
    

    We have a ListBox bound to the Customers property of MyViewModel, buttons where their Click event has been attached to the MoveSelection methods, and the Customer fields are bound to the Customers/ property, which is short for Customers.CurrentItem.

    Assuming this is the MainWindow of the WPF app all we need to do next is set its DataContext to MyViewModel. This can be done by adding the following to its constructor in the code-behind:

    public MainWindow()
    {
        this.DataContext = new MyViewModel();
    
        InitializeComponent();
    }
    

    Everything should be setup now so you can build and run the application. It will look something like this:

    Screenshot

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

Sidebar

Related Questions

Here's the issue: I have a list of App names that I want to
Python beginner here, I have a list of lists and want to refer to
James here. I'm working on a site that I want to have the same
Here is an example; I have list of numbers (1,5,8,36) and I want these
Hi i have a table where i list different values. Now i want to
I have a page that I want to have a list of items (header
I have a Canvas with custom UserControls in it. Now I want to be
I have a list of images and I want to wrap every 2 images
Placing an image inside a Span (here : HtmlGenericControl ) programmatically Want to have
I want to have a page redirect to another. Here is the situation: I

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.