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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:38:19+00:00 2026-05-19T05:38:19+00:00

Im working on a stylish ColorPicker Control and it work good, but I have

  • 0

Im working on a stylish ColorPicker Control and it work good, but I have problems with reinitialization.

I have DP called BaseBrushes witch looks like this

public ObservableCollection<Brush> BaseBrushes
    {
        get { return (ObservableCollection<Brush>)GetValue(BaseBrushesProperty); }
        set { SetValue(BaseBrushesProperty, value); }
    }

    // Using a DependencyProperty as the backing store for BaseBrushes.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty BaseBrushesProperty =
        DependencyProperty.Register("BaseBrushes", typeof(ObservableCollection<Brush>), typeof(ColorPicker), new UIPropertyMetadata(new ObservableCollection<Brush>()));

and on XAML site, I set it like this

<gc:ColorPicker Margin="0,15,0,0" SelectedBrush="#FF1E65C4" PaletteSize="6" StepSize="25">
   <gc:ColorPicker.BaseBrushes>
    <SolidColorBrush Color="Red"/>
    <SolidColorBrush Color="Blue"/>
    <SolidColorBrush Color="Orange"/>
    <SolidColorBrush Color="Green"/>
    <SolidColorBrush Color="Yellow"/>
    <SolidColorBrush Color="Black"/>
    <SolidColorBrush Color="White"/>
   </gc:ColorPicker.BaseBrushes>
  </gc:ColorPicker>

My problem is now, every time I open a window with that ColorPicker, it adds all the Brushes again to the List, so on second view I have 14 Colors and not 7.

I can clear the List in BeginInit() method, but I don’t think it’s a right solution.
I think this behavior is not normal, so I don’t see something.

Please if somebody knows somethign, help me

With Best Regards
Dima

  • 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-19T05:38:20+00:00Added an answer on May 19, 2026 at 5:38 am

    It is because in your implementation the default value of BaseBrushes is a single ObservableCollection. Resetting the size is still not what you want because all ColorPickers will still share the same BaseBrushes collection.

    You can simply create a new empty collection for BaseBrushes in the ColorPicker constructor:

    BaseBrushes = new ObservableCollection<Brush>();
    

    See the section Writing Collection Properties in this article for more details:

    • XAML and Custom Classes for WPF
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working example: http://alpha.jsfiddle.net/gTpWv/ Both of the methods work separately, but once regexp for smilies
Working with a Lucene index, I have a standard document format that looks something
We are working on a stylish screensaver that we would like to publish on
I have a contact form on site which used to work, but since last
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
Working on the problems on Project Euler to try to learn Clojure. I'm on
Working with MS Access for the first time and coming across a few problems
Working on a website http://www.ArenaText.com written in asp.net with Microsoft AJAX control toolkit. iPad
Working in Java: I have a JFrame class, and separate classes for my two
Working on game. I have a movable basket and a - for now -

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.