Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

[WPF] data binding and SetValue()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 15 Jun 2007 08:01 GMT
I have a color chooser class
class ColorPicker : Control
{
   public byte R { get; set; }
   public byte G { get; set; }
   public byte B { get; set; }
   public Color Color { get; set; }
}

All are dependency properties.
All these dependency properties are obviously related, when Red change,
Color change and vice versa.

Now I wonder how to update them as a whole.

If I do it directly mysefl as in:
When R change I call SetValue(ColorProperty, newValue)
That feel wrong.

Because if the user call, let's say:
ClearValue(ColorProperty) I end up calling SetValue(RProperty, ..), while I
should in fact clear it...

does it makes sense?
How should I synchronize values?
Nicholas Paldino [.NET/C# MVP] - 15 Jun 2007 18:37 GMT
Lloyd,

   Are you attaching an event handler to the DependencyProperty instance
for when those values change?  You should be able to set event handlers for
each of them (or rather, one for the R, G, B, values, and one for the Color
value) and then modify the values in the event handler.  When you call
SetValue from the event handler, it should prevent the setting of the values
from triggering the respective change events, and subsequently, an endless
loop.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I have a color chooser class
> class ColorPicker : Control
[quoted text clipped - 21 lines]
> does it makes sense?
> How should I synchronize values?
Lloyd Dupont - 16 Jun 2007 16:08 GMT
Hi Nicholas,

My worry are not from endless loop which I know how to prevent, but more
from other problem which I'm not sure it's even relevant...
(the fact that I'm calling SetValue() sometime when ClearValue() would be
more appropriate)

Signature

Regards,
Lloyd Dupont
NovaMind Software
Mind Mapping at its best
www.nova-mind.com

> Lloyd,
>
[quoted text clipped - 31 lines]
>> does it makes sense?
>> How should I synchronize values?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.