Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

[WPF] data binding and SetValue()

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-15-2007   #1 (permalink)
Lloyd Dupont
Guest


 

[WPF] data binding and SetValue()

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?


My System SpecsSystem Spec
Old 06-15-2007   #2 (permalink)
Nicholas Paldino [.NET/C# MVP]
Guest


 

Re: [WPF] data binding and SetValue()

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.


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

"Lloyd Dupont" <net.galador@ld> wrote in message
news:uPdO8rxrHHA.1296@TK2MSFTNGP06.phx.gbl...
>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?



My System SpecsSystem Spec
Old 06-16-2007   #3 (permalink)
Lloyd Dupont
Guest


 

Re: [WPF] data binding and SetValue()

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)

--
Regards,
Lloyd Dupont
NovaMind Software
Mind Mapping at its best
www.nova-mind.com
"Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard.caspershouse.com> wrote in
message news:u2gXYN3rHHA.3432@TK2MSFTNGP02.phx.gbl...
> 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.
>
>
> --
> - Nicholas Paldino [.NET/C# MVP]
> - mvp@spam.guard.caspershouse.com
>
> "Lloyd Dupont" <net.galador@ld> wrote in message
> news:uPdO8rxrHHA.1296@TK2MSFTNGP06.phx.gbl...
>>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?

>
>


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom data binding Matthijs ter Woord Avalon 0 02-16-2007 10:32 AM
Data binding in a FlowDocument Mark at S&W Avalon 0 05-13-2006 09:55 PM
data binding Joerg Engel Avalon 1 03-22-2006 03:18 AM
Data binding with DataGrid Vijay Avalon 1 02-21-2006 01:36 PM
data binding in viewport3d Robin Senior Avalon 11 02-14-2006 05:19 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51