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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:56:58+00:00 2026-06-12T22:56:58+00:00

I have 2 classes, one inside the other, and a prop with an ObservableCollection

  • 0

I have 2 classes, one inside the other, and a prop with an ObservableCollection of the class with the sub-class collection. But I’m having a serious trouble in displaying the whole thing.

First my data, this is what I’ve got: (it may clarify my issue)

public class MyItem
{
    public string Id { get; set; }
    public string Front { get; set; }
    public Props.StateSemaphore Semaphore{ get; set; } // this is an enum w/ints
    public string ToolTip { get; set; }
    public string Architect { get; set; }
    public string Status { get; set; }

    public MyItem(){}
    public MyItem(string id, string front, 
            Props.StateSemaphore semaphore, string toolTip, 
            string architect, string status)
    {
        Id = id;
        Front = frente;
        Semaphore = semaphore;
        ToolTip = toolTip;
        Architect = architect;
        Status = status;
    }
}

public class MyTab
{
    public List<MyItem> MyItems { get; set; }
    public string Environment { get; set; }
    public MyTab() { }
    public MyTab(string environment)
    {
        Environment = environment;
        MyItems = new List<MyItem>();
    }
}

And a prop on the PageExample.xaml.cs

  private ObservableCollection<MyTab> myPanel;
  public ObservableCollection<MyTab> MyPanel
  {
      get { return myPanel; }
      set { myPanel = value; }
  }

The idea is to display for each Environment a Grid of MyItems with an image(Red, Yellow or Green) on the semaphore enum

@Edit: This is almost working! Only the images won’t display.

This is My XAML but im newbie on wpf so It’s obvious I’m missing something.

<Page x:Class="MyBoard.PageMain"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:w="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:MyBoard"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
      Title="PageMain">
       <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Center">
        <DataGrid Name="EnvironmentDataGrid" IsReadOnly="True" ItemsSource="{Binding}" AutoGenerateColumns="False">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Id}" Header="Id"/>
                <DataGridTextColumn Binding="{Binding Front}" Header="Front"/>
                <DataGridTemplateColumn Header="Semaphore">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Semaphore}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Binding="{Binding ToolTip}" Header="ToolTip"/>
                <DataGridTextColumn Binding="{Binding Architect}" Header="Architect"/>
                <DataGridTextColumn Binding="{Binding Status}" Header="Status"/>
            </DataGrid.Columns>

            <DataGrid.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <TextBlock Text="{Binding Path=Environment}" FontWeight="Bold" Padding="3"/>
                            </StackPanel>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander>
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Path=Name}" />
                                                    <TextBlock Text="{Binding Path=ItemCount}" Margin="8,0,4,0"/>
                                                    <TextBlock Text="Element(s)"/>
                                                </StackPanel>
                                            </Expander.Header>
                                            <ItemsPresenter />
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>
        </DataGrid>
    </Grid>
</Page>

These are my questions:

  1. How is the correct way to write the XAML? @Edit: DONE!
  2. How and where to bind
    the semaphore image to the datagrid?

@Edit: Semaphore is now a RelativeUri, because I didnt understand this answer.
I mean, I get the idea but not this thing:

<MultiBinding Converter={StaticResource catMultiConverter}>
      <Binding .../>
      <Binding .../>
    </MultiBinding>

With the RelativeUri and all It still does not display.

  • 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-12T22:57:00+00:00Added an answer on June 12, 2026 at 10:57 pm
    1. See here to find out how to set DataGrid.Columns and how to Bind them.
    2. Check here how to convert semaphore enums into Images thru Converter and DataGridTemplateColumn.CellTemplate.
    3. See here how to use grouping in DataGrid to group on the Environment property so that same Environment items are shown arranged under one group.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, one that inherits from the other. The base class is
I have two classes one of which inherits from the other. Im trying to
I have two classes (MVC view model) which inherits from one abstract base class.
I have two classes, one is a standard activity , the other a service
I have two classes, and want to include a static instance of one class
I have two classes under QT, one to make a form, the other to
I have 2 classes where I have one to send commands to a socket,
I have some classes that, for one reason or another, cannot be or need
Starting to learn Canvas and have two classes so far (main one to call
In one of my projects, I have some classes that represent entities that cannot

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.