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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:55:45+00:00 2026-06-08T06:55:45+00:00

Hopefully a simple question. I have a custom control with a dependency property that

  • 0

Hopefully a simple question. I have a custom control with a dependency property that contains a list of another custom control.

public static readonly DependencyProperty BlockObjectsProperty = DependencyProperty.Register("BlockObjects", typeof(FreezableCollection<BlockObject>), typeof(Block), new FrameworkPropertyMetadata(new FreezableCollection<BlockObject>(), null));
public FreezableCollection<BlockObject> BlockObjects
{
     get { return (FreezableCollection<BlockObject>)base.GetValue(BlockObjectsProperty); }
     set { base.SetValue(BlockObjectsProperty, value); }
}

this is then used within xaml to populate the controls

<Viewbox Grid.Row="2" Stretch="Uniform">
    <ItemsControl x:Name="tStack" ItemsSource="{TemplateBinding BlockObjects}" ContextMenu="{StaticResource BodyContextMenuKey}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Vertical"  VerticalAlignment="Stretch" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
     </ItemsControl>
</Viewbox>

My problem now is i want to serialize this out to a file but i’m getting ‘Cannot serialize a generic type ‘System.Windows.FreezableCollection`’ when using XamlWriter.Save. if this was a normal class i could use attributes to describe the way it should be serialized (right?) but its a static dependency property so how do i get this to serialize?

  • 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-08T06:55:46+00:00Added an answer on June 8, 2026 at 6:55 am

    Ok Silly me there is alot of information about this all over the net, the simple solution is to take the generic freezablecollection and derive a none generic class as below.

    public class BlockObjectCollection : FreezableCollection<BlockObject>
    {
    }
    

    then replace the dependency properties

        public static readonly DependencyProperty BlockObjectsProperty = DependencyProperty.Register("BlockObjects", typeof(BlockObjectCollection), typeof(Block), new FrameworkPropertyMetadata(new BlockObjectCollection(), null));
        public BlockObjectCollection BlockObjects
        {
            get { return (BlockObjectCollection)base.GetValue(BlockObjectsProperty); }
            set { base.SetValue(BlockObjectsProperty, value); }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a quick and hopefully simple question that I hope someone can help
hopefully this is a simple question. I have a simple custom forum on my
This is a (hopefully) really simple question - I have been told recently that
Simple question hopefully. We have a style sheet that is over 3000 lines long
I have hopefully a simple question. I have a ASPxGridView that I need to
Hopefully this is a very simple question. I have a makefile pattern rule that
This is hopefully a simple question: I have an OpenGL texture and would like
I have a (hopefully) simple question. Is it possible to use SSHD tunneling to
I'm just getting started with Require.JS and I have a (hopefully) simple question. I'm
Hopefully a simple question although one I have found impossible to answer myself using

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.