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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:54:44+00:00 2026-05-27T12:54:44+00:00

I have a business object that can be edited via PropertyGrid. It contains list

  • 0

I have a business object that can be edited via PropertyGrid. It contains list of labels (let’s say strings for simplification).

public class MyObject
{
    // bunch of properties here, cut for readiness
    public LabelsList List {get;set;}
    // ...
}

List of labels is simple class inherited from List :

public class LabelsList : List<T>
{}

For proper displaying of my object in property grid (by that i mean expandable editable list of labels too) i’ve implemented an ICustomTypeDescriptor for LabelsList, changing notably GetProperties() method :

public PropertyDescriptorCollection GetProperties()
{
    var props = new PropertyDescriptorCollection(null);
    for (var i = 0; i < this.Count; i++)
    {            
        var descriptor = new LabelsListPropertyDescriptor(this, i);
        props.Add(descriptor);
    }
    return props;
}

Now the problem – when i use standard XAML serialization by calling XamlWriter.Save(this) on underlying type, it adds excessive LabelsList.LabelName tag inside resulting XAML :

<wpfdl:LabelsList>
    *<wpfdl:LabelsList.Label1Name>*
        <wpfdl:Label LabelText="Label1Name"/>
    *</wpfdl:LabelsList.Label1Name>*
...
</wpfdl:LabelsList>

That actually disables following (MyObject)XamlReader.Parse(exportedXaml) call because label names can contain special characters. What is proper workaround to achieve both correct editing and serializing of objects? Thanks in advance.
update
Made unnecessary tags go away by changing respective PropertyDescriptor :

public override bool ShouldSerializeValue(object component)
{
    return false;
}

Resulting xaml is as follows (Primitive is name of my object custom type):

<Primitive>
    <Primitive.Labels>
        <Label LabelText="text1" LabelPosition="position1" />
        <Label LabelText="text2" LabelPosition="position2" />
    </Primitive.Labels>
</Primitive>

That’s pretty much it, but now <LabelsList> tags inside <Primitive.Labels> are missing :

'Collection property 'WPF_DrawingsTest.Primitive'.'Labels' is null.' Line number '1' and line position '96'.

Still need to make this work. Maybe test project will help to see what i’m looking for :
Test project, 100 kb, no viruses

  • 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-27T12:54:45+00:00Added an answer on May 27, 2026 at 12:54 pm

    Refactored initial business object, serialization/deserialization now is done automatically and works fine.

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

Sidebar

Related Questions

Let's say I have a business object that is very expensive to instantiate, and
Lets say that you have a business object whose current state implies that there
Let's say we have a business object, let's call it a Foo , which
I have a business object that compiles into a DLL that handles all calculations
I have a service object that is responsible for some business logic validation. What
I have a business object project, which contains composite structure: public class Tree {
I have several business rules for my FormPartB object that depend on related entities
I have a Business Object which contains a DataTable among other properties. I pass
Assume I have a business object that has some properties that should be read-only.
I have a working prototype that can download managed code via the AssemblyPart loader,

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.