+1
That's a nice summary. Kudos to you Patrick!
From: [email protected] [mailto:[email protected]]
On Behalf Of Patrick Klug <[email protected]>
Sent: Tuesday, 7 September 2010 8:44 AM
To: [email protected]
Subject: Re: ozwpf Digest, Vol 8, Issue 1
I had started a Common WPF Pitfalls on stackoverflow and this has been
one of the suggested items:
http://stackoverflow.com/questions/2597591/common-wpf-pitfalls
As a rule, you should not put any logic in the getter or setter of a
dependency property.
Not only will the Binding system ignore the logic but also you (and
anyone else having access) can use {Property}.SetValue() and
{Property}.GetValue() to set the value of this property without going
through the setter/getter.
cheers,
Patrick
On Tue, Sep 7, 2010 at 12:00 PM, <[email protected]> wrote:
Send ozwpf mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of ozwpf digest..."
Today's Topics:
1. Dependency properties (Stephen Price)
2. RE: Dependency properties ([email protected])
3. RE: Dependency properties (Greg Keogh)
4. Re: Dependency properties (Winston Pang)
5. Re: Dependency properties (Stephen Price)
----------------------------------------------------------------------
Message: 1
Date: Mon, 6 Sep 2010 10:30:37 +0800
From: Stephen Price <[email protected]>
Subject: Dependency properties
To: ozWPF <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
hey all,
Someone on the team suggested some changes to a property that I had
due to something to do with the WPF binding engine not using the
property to get the underlaying values. This threw me and I've not had
a chance to research/proof this but thought I'd throw it out here for
comment.
public string Filter
{
get
{
if(somecondition) return somethingElse;
return (string)GetValue(FilterProperty);
}
set
{
SetValue(FilterProperty, value);
}
}
so I have a filter property with some logic in it, but apparently if I
bind to this the wpf binding goes straight to the FilterProperty
instead of my Filter property. I'll research this when I have a spare
min unless someone can debunk it. :)
have a great day!
Stephen
------------------------------
Message: 2
Date: Mon, 6 Sep 2010 10:44:04 +0800
From: [email protected]
Subject: RE: Dependency properties
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"
That's right. For performance, the framework will go straight to the
backing store, bypassing your property.
As a general rule of thumb, only your own code that uses the property
will go through the property (though you can go straight to the backing
store yourself if you want).
To ensure code gets run, I normally use the OnPropertyChanged override.
This always fires after the property has changed, even if the backing
store approach was used.
Carl.
Carl Scarlett
Senior .NET/WPF Developer, UX Designer - Genesis Team
IT Applications Delivery | Bankwest
A: Level 5, 199 Hay Street | Perth | Western Australia | 6004
P: (08) 9449 8703
M: 0408 913 870
E: [email protected]
From: [email protected] [mailto:[email protected]]
On Behalf Of Stephen Price <[email protected]>
Sent: Monday, 6 September 2010 10:31 AM
To: ozWPF <[email protected]>
Subject: Dependency properties
hey all,
Someone on the team suggested some changes to a property that I had
due to something to do with the WPF binding engine not using the
property to get the underlaying values. This threw me and I've not had
a chance to research/proof this but thought I'd throw it out here for
comment.
public string Filter
{
get
{
if(somecondition) return somethingElse;
return (string)GetValue(FilterProperty);
}
set
{
SetValue(FilterProperty, value);
}
}
so I have a filter property with some logic in it, but apparently if I
bind to this the wpf binding goes straight to the FilterProperty
instead of my Filter property. I'll research this when I have a spare
min unless someone can debunk it. :)
have a great day!
Stephen
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
________________________________________________________________________
_______
This email has been scanned by the Bankwest Email Security System.
________________________________________________________________________
_______
________________________________________________________________________
_______
Unencrypted electronic mail is not secure and may not be authentic.
If you have any doubts as to the contents please telephone to confirm.
This electronic transmission including any attachments is intended only
for those to whom it is addressed. It may contain copyright material or
information that is confidential, privileged or exempt from disclosure
by law.
Any claim to privilege is not waived or lost by reason of mistaken
transmission
of this information. If you are not the intended recipient you must not
distribute or copy this transmission and should please notify the
sender.
Your costs for doing this will be reimbursed by the sender.
We do not accept liability in connection with computer virus, data
corruption,
delay, interruption, unauthorised access or unauthorised amendment.
________________________________________________________________________
_______
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://prdlxvm0001.codify.net/pipermail/ozwpf/attachments/20100906/cbef3
b30/attachment-0001.html
------------------------------
Message: 3
Date: Mon, 6 Sep 2010 13:07:12 +1000
From: "Greg Keogh" <[email protected]>
Subject: RE: Dependency properties
To: "'ozWPF'" <[email protected]>
Message-ID: <001801cb4d70$9a0bc690$ce2353...@net>
Content-Type: text/plain; charset="us-ascii"
Yeah, you're not supposed to put logic in the get/set code. I think a
few of
my books mentioned this in passing. Your code may not get called when
binding happens or the XAML is parsed -- Greg
------------------------------
Message: 4
Date: Mon, 6 Sep 2010 13:13:44 +1000
From: Winston Pang <[email protected]>
Subject: Re: Dependency properties
To: ozWPF <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
Yeah, specifically WPF Unleashed mentions this. Logic should really go
in
the CoerceCallbacks, or PropertyChanged, etc ones.
On Mon, Sep 6, 2010 at 1:07 PM, Greg Keogh <[email protected]> wrote:
> Yeah, you're not supposed to put logic in the get/set code. I think a
few
> of
> my books mentioned this in passing. Your code may not get called when
> binding happens or the XAML is parsed -- Greg
>
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://prdlxvm0001.codify.net/pipermail/ozwpf/attachments/20100906/bd9a9
42e/attachment-0001.html
------------------------------
Message: 5
Date: Mon, 6 Sep 2010 11:42:46 +0800
From: Stephen Price <[email protected]>
Subject: Re: Dependency properties
To: ozWPF <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=windows-1252
thanks all... that's kind of crazy, but glad I know about it now.
I'm assuming its the same case for Silverlight?
cheers,
Stephen
On Mon, Sep 6, 2010 at 10:44 AM, <[email protected]> wrote:
> That?s right.? For performance, the framework will go straight to the
> backing store, bypassing your property.
>
>
>
> As a general rule of thumb, only your own code that uses the property
will
> go through the property (though you can go straight to the backing
store
> yourself if you want).
>
>
>
> To ensure code gets run, I normally use the OnPropertyChanged
override.
> This always fires after the property has changed, even if the backing
store
> approach was used.
>
>
>
> Carl.
>
>
>
> Carl Scarlett
>
> Senior .NET/WPF Developer, UX Designer - Genesis Team
>
> IT Applications Delivery | Bankwest
>
> A: Level 5, 199 Hay Street | Perth | Western Australia | 6004
>
> P: (08) 9449 8703
>
> M: 0408 913 870
>
> E: [email protected]
>
>
>
>
>
>
>
>
>
> From: [email protected]
[mailto:[email protected]] On
> Behalf Of Stephen Price <[email protected]>
> Sent: Monday, 6 September 2010 10:31 AM
> To: ozWPF <[email protected]>
> Subject: Dependency properties
>
>
>
> hey all,
>
> Someone on the team suggested some changes to a property that I had
> due to something to do with the WPF binding engine not using the
> property to get the underlaying values. This threw me and I've not had
> a chance to research/proof this but thought I'd throw it out here for
> comment.
>
> public string Filter
> {
> get
> {
> if(somecondition) return somethingElse;
> return (string)GetValue(FilterProperty);
> }
> set
> {
> SetValue(FilterProperty, value);
> }
> }
>
> so I have a filter property with some logic in it, but apparently if I
> bind to this the wpf binding goes straight to the FilterProperty
> instead of my Filter property. I'll research this when I have a spare
> min unless someone can debunk it. :)
>
> have a great day!
> Stephen
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
>
________________________________________________________________________
_______
>
> This email has been scanned by the Bankwest Email Security System.
>
________________________________________________________________________
_______
>
>
________________________________________________________________________
_______
> Unencrypted electronic mail is not secure and may not be authentic.
> If you have any doubts as to the contents please telephone to confirm.
>
> This electronic transmission including any attachments is intended
only
> for those to whom it is addressed. It may contain copyright material
or
> information that is confidential, privileged or exempt from disclosure
by
> law.
> Any claim to privilege is not waived or lost by reason of mistaken
> transmission
> of this information. If you are not the intended recipient you must
not
> distribute or copy this transmission and should please notify the
sender.
> Your costs for doing this will be reimbursed by the sender.
>
> We do not accept liability in connection with computer virus, data
> corruption,
> delay, interruption, unauthorised access or unauthorised amendment.
> ___________________________________
> ____________________________________________
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
>
------------------------------
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
End of ozwpf Digest, Vol 8, Issue 1
***********************************
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
________________________________________________________________________
_______
This email has been scanned by the Bankwest Email Security System.
________________________________________________________________________
_______
_______________________________________________________________________________
Unencrypted electronic mail is not secure and may not be authentic.
If you have any doubts as to the contents please telephone to confirm.
This electronic transmission including any attachments is intended only
for those to whom it is addressed. It may contain copyright material or
information that is confidential, privileged or exempt from disclosure by law.
Any claim to privilege is not waived or lost by reason of mistaken transmission
of this information. If you are not the intended recipient you must not
distribute or copy this transmission and should please notify the sender.
Your costs for doing this will be reimbursed by the sender.
We do not accept liability in connection with computer virus, data corruption,
delay, interruption, unauthorised access or unauthorised amendment.
_______________________________________________________________________________
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
_____________________________________________________________________________________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf