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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:41:17+00:00 2026-05-22T18:41:17+00:00

I have a control with this xaml: <Controls:TreeView x:Name=MachineGroupsTree Style={StaticResource MachineGroupStyle} > <i:Interaction.Triggers> <i:EventTrigger

  • 0

I have a control with this xaml:

        <Controls:TreeView x:Name="MachineGroupsTree" Style="{StaticResource MachineGroupStyle}" >
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectedItemChanged">
                    <i:InvokeCommandAction Command="{Binding SetCurrentManagedObjectNodeCommand}" CommandParameter="{Binding SelectedItem, ElementName=MachineGroupsTree, Mode=OneWay}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <Controls:TreeViewItem>
                <Controls:TreeViewItem.HeaderTemplate>
                    <DataTemplate>
                        <TextBlock Text="Loading..." Style="{StaticResource LoadingStyle}" />
                    </DataTemplate>
                </Controls:TreeViewItem.HeaderTemplate>
            </Controls:TreeViewItem>
        </Controls:TreeView>

With this code-behind:

            public static readonly DependencyProperty ItemsSourceProperty = 
DependencyProperty.Register( "ItemsSource", typeof( IEnumerable ), typeof( 
MachineGroupTreeViewControl ), new PropertyMetadata( null, new PropertyChangedCallback( 
OnItemSourceChanged ) ) );


        public IEnumerable ItemsSource {
            get {
                return ( IEnumerable )GetValue( ItemsSourceProperty );
            }
            set {
                ClearValue( ItemsSourceProperty );
                SetValue( ItemsSourceProperty, value );
            }
        }

        static void OnItemSourceChanged( object sender,
            DependencyPropertyChangedEventArgs args ) {
            // Get reference to self
            MachineGroupTreeViewControl source = ( MachineGroupTreeViewControl )sender;

            // Add Handling Code    

            // ---------------------------------------------
            // EXCEPTION HERE !!!
            source.MachineGroupsTree.ItemsSource = ( IEnumerable )args.NewValue;
        }

And I get the well known “Items collection must be empty before using ItemsSource” exception, but I don’t understand why, there is no added item in the xaml!

  • 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-22T18:41:18+00:00Added an answer on May 22, 2026 at 6:41 pm

    Sure there is:

    <Controls:TreeViewItem>
        <Controls:TreeViewItem.HeaderTemplate>
            <DataTemplate>
                <TextBlock Text="Loading..." Style="{StaticResource LoadingStyle}" />
            </DataTemplate>
        </Controls:TreeViewItem.HeaderTemplate>
    </Controls:TreeViewItem>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this control template that I am writing: <Style TargetType={x:Type controls:InfoBar}> <Setter Property=Template>
I have this custom wpf user control: ShowCustomer.xaml: <UserControl x:Class=TestControlUpdate2343.Controls.ShowCustomer xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml> <Grid> <TextBlock
I have this User Control XAML: <Window x:Class=MyProj.Dialog 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:shell=http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell mc:Ignorable=d>
I have the following code: foreach (var control in this.Controls) { } I want
I have a TreeView control that I have created in XAML in a WPF
I have this XAML for a UserControl: <UserControl x:Class=SW.Resources.Controls.HistoryProgressBox xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:d=http://schemas.microsoft.com/expression/blend/2008 xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 mc:Ignorable=d
I have this control (see picture). I like when check one option in this
say I have this control: public partial class bloc999 : UserControl { bloc999Data mainBlock
I have a control that handles commenting. In this control, I have set a
I have a user control let say UC1 . This user control have viewmodel

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.