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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:28:49+00:00 2026-05-18T04:28:49+00:00

I have 2 user controls one named Filters and one named FilterItem Filter looks

  • 0

I have 2 user controls one named Filters and one named FilterItem

Filter looks like this:

<UserControl xmlns:my="clr-namespace:AttorneyDashboard.Views.UserControls"  x:Class="AttorneyDashboard.Views.UserControls.Filters"
    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"
    xmlns:helpers="clr-namespace:AttorneyDashboard.Helpers"
    mc:Ignorable="d"
    d:DesignHeight="150" d:DesignWidth="590" x:Name="FiltersRoot">
    <Grid>
        <ListBox x:Name="myListBox" ItemsSource="{Binding Path=FilterItems, ElementName=FiltersRoot}" >
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <my:FilterItem ColumnsList="{Binding Path=Columns_, ElementName=FiltersRoot}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>

Code Behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Collections.ObjectModel;
using System.Diagnostics;
using AttorneyDashboard.Helpers;

namespace AttorneyDashboard.Views.UserControls
{
    public class MyItems
    {
        public string Header { get; set; }
    }
    public partial class Filters : UserControl
    {
        public Filters()
        {
            InitializeComponent();

        }
        private DependencyProperty FilterItemsProperty = DependencyProperty.Register("FilterItems", typeof(ObservableCollection<FilterDescriptor>), typeof(Filters), new PropertyMetadata(null, new PropertyChangedCallback(OnChangeFilterItems)));
        public ObservableCollection<FilterDescriptor> FilterItems
        {
            get
            {
                return (ObservableCollection<FilterDescriptor>)GetValue(FilterItemsProperty);
            }
            set
            {
                SetValue(FilterItemsProperty, value);
            }
        }


        public static void OnChangeFilterItems(DependencyObject d, DependencyPropertyChangedEventArgs e)
        { 
        }



        public List<MyItems> Columns_
        {
            get
            {
                List<MyItems> list = new List<MyItems>();
                list.Add(new MyItems() { Header = "test1" });
                list.Add(new MyItems() { Header = "test2" });
                list.Add(new MyItems() { Header = "test3" });
                return list;
            }
        }
    }
}

FilterItems looks like this

<UserControl x:Class="AttorneyDashboard.Views.UserControls.FilterItem"
    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"
    d:DesignHeight="23" d:DesignWidth="590" xmlns:my="clr-namespace:AttorneyDashboard.Helpers" x:Name="FilterItemRoot">
    <StackPanel Orientation="Horizontal">
        <ComboBox Height="23" HorizontalAlignment="Left" Name="FieldName" VerticalAlignment="Top" Width="120" Margin="5,0,0,0" ItemsSource="{Binding Path=ColumnsList, ElementName=FilterItemRoot}" SelectedItem="{Binding PropertyPath, Mode=TwoWay}" DisplayMemberPath="Header"/>
    </StackPanel>
</UserControl>

Code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using AttorneyDashboard.Helpers;
using System.Windows.Data;

namespace AttorneyDashboard.Views.UserControls
{
    public partial class FilterItem : UserControl
    {
        public FilterItem()
        {
            InitializeComponent();
        }

        private DependencyProperty ColumnsListProperty = DependencyProperty.Register("ColumnsList", typeof(List<MyItems>), typeof(FilterItem), new PropertyMetadata(null, new PropertyChangedCallback(OnChangeColumns)));
        public List<MyItems> ColumnsList
        {
            get
            {
                return (List<MyItems>)GetValue(ColumnsListProperty);
            }
            set
            {
                SetValue(ColumnsListProperty, value);
            }
        }

        public static void OnChangeColumns(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
        }
    }
}

The number of FilterItems is ok (this means that FilterItems binding works ok), but only the Combobox of the last FilterItem is populated…
And I do not know what exactly is wrong…

Update:
I found why but I stll do not know a solution…
It seams that the content of FilterItem is binded before his properties are..
So the combobox in FilterItem is binded before the Columns property is binded…

  • 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-18T04:28:50+00:00Added an answer on May 18, 2026 at 4:28 am

    Your code in FilterItem

     private DependencyProperty ColumnsListProperty = DependencyProperty
         .Register("ColumnsList", typeof(List<MyItems>), typeof(FilterItem), 
             new PropertyMetadata(null, new PropertyChangedCallback(OnChangeColumns)));
    

    Please, make it static:

     private **static** DependencyProperty ColumnsListProperty = DependencyProperty
         .Register("ColumnsList", typeof(List<MyItems>), typeof(FilterItem), 
             new PropertyMetadata(null, new PropertyChangedCallback(OnChangeColumns)));
    

    Thats it.

    P.S. : in Filters make dependency property static too, generally do it anywhere 🙂

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

Sidebar

Related Questions

I have two User Controls already created now I want to use one as
I have two user controls, in one of them I have a textbox, i
I have WPF Application where I have One main form and other user controls
I have a a bunch of user controls(about 15, one for each record) in
I've got many user controls like this: PageManageCustomers.xaml.cs: public partial class PageManageCustomers : BasePage
I have an user control named GraphPanel. It has two dependency properties, one custom,
I have one user control named XtraTreeList(It is combination of the treeview and datagridview)
I have an application which loads dlls with user controls dynamically. Inside one of
I have added a usercontrol to my project like this: Public Sub clickAutoDrillLeft(ByVal sender
I have a user control that has a few public properties, one is an

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.