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

  • Home
  • SEARCH
  • 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 7987979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:18:13+00:00 2026-06-04T12:18:13+00:00

I need to put my ObservableCollection<ValidationMessage> into my TextBlock . Here is my code.

  • 0

I need to put my ObservableCollection<ValidationMessage> into my TextBlock. Here is my code. Right now it is showing the Item and the SubItems, but where the messages show it has System.Collections.ObjectModel.ObservableCollection'1[ValidationWPF.DataSources.‌​ValidationMessages].

I think this is because it cannot put an ObservableCollection into the TextBlock.

XAML:

<UserControl x:Class="ValidationWPF.ValidationUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:local="clr-namespace:ValidationWPF.DataSources"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <DataTemplate x:Key="Messages">
            <TextBlock Text="{Binding Message}"/>
        </DataTemplate>



    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">

        <telerik:RadTreeView x:Name="radTreeView" Margin="8">
            <telerik:RadTreeView.ItemTemplate>



                <HierarchicalDataTemplate ItemsSource="{Binding SubItems}">
                    <TextBlock Text="{Binding item}" />
                </HierarchicalDataTemplate>

            </telerik:RadTreeView.ItemTemplate>
        </telerik:RadTreeView>

    </Grid>
</UserControl>

ValidationMessage Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ValidationWPF.DataSources
{
    public class ValidationMessage
    {
        public ValidationMessage(string Message)
        {
            this.Message = Message;
        }

        public string Message
        {
            get;
            set;
        }

    }
}

ValidationItem Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace ValidationWPF.DataSources
{
   public class ValidationItem : ObservableCollection<ValidationItem>
    {
        public ValidationItem()
        {
            SubItems = new ObservableCollection<ValidationItem>();


        }


        public ObservableCollection<ValidationMessage> Message
        {
            get;
            set;
        }

        public string item
        {
            get;
            set;
        }

        public IList<ValidationItem> SubItems
        {
            get;
            set;
        }

        public static IList<ValidationItem> GetItems(string name)
        {
            var Validation = new ObservableCollection<ValidationItem>();


            var item = new ValidationItem();
            item.item = "Customer";


            var subItem = new ValidationItem();
            subItem.item = "Name";
            item.SubItems.Add(subItem);

            var Message = new ValidationItem();
            Message.item = new ObservableCollection<ValidationMessage>().ToString();
            subItem.SubItems.Add(Message);






            Validation.Add(item);

            return Validation;

        }
    }
}

Thank you for your help!!

  • 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-04T12:18:14+00:00Added an answer on June 4, 2026 at 12:18 pm

    I ended up doing it a different and cleaner way.

    XAML:

    <UserControl x:Class="ValidationWPF.ValidationUserControl"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 xmlns:local="clr-namespace:ValidationWPF.DataSources"
                 mc:Ignorable="d" 
                 d:DesignHeight="300" d:DesignWidth="300">
        <UserControl.Resources>
            <!--<local:CollectionConverter x:Key="CollectionConverter"/>
                <DataTemplate x:Key="Messages">
                <TextBlock Text="{Binding Message}"/>
            </DataTemplate>--> 
    
    
    
    
        </UserControl.Resources>
        <Grid x:Name="LayoutRoot" Background="White">
    
            <telerik:RadTreeView x:Name="radTreeView" Margin="8" ItemsSource="{Binding Errors}">
                <telerik:RadTreeView.ItemTemplate>
                     <HierarchicalDataTemplate ItemsSource="{Binding SubItems}" >
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="{Binding Description}"/>
    
                            <ListBox Grid.Row="1" ItemsSource="{Binding Messages}">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding Message}"/>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </Grid>
    
                    </HierarchicalDataTemplate>
    
                </telerik:RadTreeView.ItemTemplate>
            </telerik:RadTreeView>
    
        </Grid>
    </UserControl>
    

    VALIDATIONMESSAGE CLASS:

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
    
        namespace ValidationWPF.DataSources
        {
            public class ValidationMessage
            {
                public ValidationMessage(string name, string Message)
                {
                    this.Message = Message;
                    this.PropertyName = name;
                }
    
                public string Message
                {
                    get;
                    set;
                }
    
                public string PropertyName { get; set; }
    
            }
        }
    
    VALIDATIONVIEWMODEL CLASS:
    
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        using System.Collections.ObjectModel;
    
        namespace ValidationWPF.DataSources
        {
            public class ValidationViewModel
            {
                public ValidationViewModel()
                {
                    this.Errors = new ObservableCollection<ValidationItem>();
    
                    ValidationItem item = new ValidationItem();
                    item.Description = "Customer";
    
                    ValidationMessage msg = new ValidationMessage("FirstName", "First name is required");
                    item.Messages.Add(msg);
    
    
                    this.Errors.Add(item);
    
                    ValidationItem item2 = new ValidationItem();
                    item2.Description = "Order";
    
                    msg = new ValidationMessage("Quantity", "Quantity must be greater than zero");
                    item2.Messages.Add(msg);
    
    
                    item.SubItems.Add(item2);
    
                }
    
                public ObservableCollection<ValidationItem> Errors { get; set; }
            }
        }
    

    VALIDATIONUSERCONTROL CLASS:

      public partial class ValidationUserControl : UserControl
        {
            public ValidationUserControl()
            {
                InitializeComponent();
                this.DataContext = new ValidationViewModel();
    
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to put $input into the file spelled.. but this code leaves the
I need to put custom headers into WCF. My Code is as follows: ServiceReference1.Service2Client
I need to put a custom hover menu from http://www.addthis.com/help/toolbox , but Rails uses
I need to put a date into the title attribute of an image so
I need to put some of the entities created via a.dbml Linq-To-Sql file into
I need order a Queryset by date in desc order, but i need put
I need to put following code in the constructor of my startup form. JohnKenedy.BusinessSQLEXPRInstaller
I have a table with some fixed columns id,title,created.., but there I need put
I need to put a control to the right of my MenuStrip. The MenuStrip
I need to put an LDAP contextSource into my Java EE container's JNDI tree

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.