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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:25:52+00:00 2026-06-06T12:25:52+00:00

I have a custom WPF control base class. This base class registers a custom

  • 0

I have a custom WPF control base class. This base class registers a custom property with the type “List<“some own type”>”.

How can I initialize the property for design time? There should always be 8 objects in the list and the user should by able to modify this objects.

I have tried to pass a default value with the PropertyMetadata object, but the collection shown in the property editor is always empty.

public class CustomPropertyTestBase : UserControl
{

    static CustomPropertyTestBase()
    {
        List<object> defaultValue = new List<object>(new object[8]);
        MyCustomObjectsProperty = DependencyProperty.Register("MyCustomObjects",
            typeof(List<object>), typeof(CustomPropertyTestBase),
            new PropertyMetadata(defaultValue));
    }

    public static DependencyProperty MyCustomObjectsProperty;

    [Category("MyCustomProperties")]
    public List<object> MyCustomObjects
    {
        get;
        set;
    }
}

EDIT:

Whenever i add a new object in the property editor, these new objects are not stored. After reopening the property editor the list is empty again.

I have attached the debugger to the designer and the get or set methods of the property are never called by the editor.

SOLUTION:

As “dowhilefor” had mentioned. I had to change the type ObservableCollection. Now the designer stores the changed list correctly.
Thanks.

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

    Something like this should work:

    public MainWindow()
        {
            InitializeComponent();
    
            if( System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                MyCustomObjects = new List<object>();
                MyCustomObjects.Add("Hello");
            }
        }
    

    But maybe its not the best solution. I remember there was some tools in expression blend to have dummy data, but can’t remember how they did it. Of course this is static and you can’t change it, but i don’t think this is possible.

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

Sidebar

Related Questions

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
In a WPF/MVVM application I have a custom control on a particular view. This
I have a custom WPF control which consist of single TextBox <UserControl HorizontalAlignment=Left x:Class=WPFDiagramDesignerControl.Components.UcWBSBlock
I have a custom control in WPF. In this I have a DependencyProperty of
So I have a WPF custom control library with a few controls. Some of
Does anyone have a good example of creating a WPF custom control or some
I have a custom WPF control MyLine that should represent or not some text
In WPF, I have a custom control that inherits from TreeView. The code is
I have a custom class say 'MyCanvas' derived from wpf Canvas class. MyCanvas has
I have a complex WPF control that for some reasons (ie. performance) is not

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.