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? 2 3287
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]
- mv*@spam.guard.caspershouse.com
"Lloyd Dupont" <net.galador@ldwrote in message
news:uP**************@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?
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]" <mv*@spam.guard.caspershouse.comwrote in
message news:u2**************@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]
- mv*@spam.guard.caspershouse.com
"Lloyd Dupont" <net.galador@ldwrote in message
news:uP**************@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?
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Roberts |
last post by:
I've been doing COM a long time, but I've just come across a behavior
with late binding that surprises me. VB and VBS are not my normal
milieux, so I'm hoping someone can point me to a document...
|
by: moondaddy |
last post by:
I'm trying to databind a dependency property in a custom control (CenterX)
to the Line.X1Property property of line. If I can correctly do this (and
the same for the 'Y' props) then when I drag my...
|
by: =?Utf-8?B?UGhpbCBKb2huc29u?= |
last post by:
Hello,
My first attempt to bind a 'detail' form to the properties on an object and
the binding is not working.
I have the following grid:
<Grid x:Name="MainGrid">
<StackPanel...
|
by: moondaddy |
last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which
has 3 content controls in it. each content control uses a style from a
resource dictionary merged into the app.xaml...
|
by: Linda Liu[MSFT] |
last post by:
Hi George,
Thank you for posting!
This is a quick note to let you know that I am doing research on this issue
and will get back to you ASAP.
I appreciate your patience!
Sincerely,
|
by: raylopez99 |
last post by:
Here I am learning WinForms and two months into it I learn there's a
WPF API that is coming out. Is this WPF out yet, and is it a threat
to WinForms, in the sense that all the library routines I...
|
by: Andy |
last post by:
Hi,
I'm trying to understand why something does work. If you create a new
WPF Applicatin project, WpfApplication6, and set the following:
MainWindow.xaml:
<Window...
|
by: furqanms |
last post by:
Hello,
I am new to WPF ,I am developing touch screen system using WPF. I am facing problem in Binding relative reference.
Here is my code :
<UserControl x:Class="uctlBrowser"
...
|
by: Kevinst |
last post by:
Hi!
Let's say I wanted to create a very simple control that is nothing but a LED. That LED can be active or inactive. Depending on that state its color changes.
What is WPFs best practice to do...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |