Click here to Skip to main content
15,915,763 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: equivalent method Dispose() in WPF? [modified] PinPopular
#realJSOP24-Jul-09 23:02
professional#realJSOP24-Jul-09 23:02 
GeneralRe: equivalent method Dispose() in WPF? Pin
Pete O'Hanlon27-Jul-09 1:59
mvePete O'Hanlon27-Jul-09 1:59 
AnswerRe: equivalent method Dispose() in WPF? Pin
Kunal Chowdhury «IN»26-Jul-09 20:21
professionalKunal Chowdhury «IN»26-Jul-09 20:21 
QuestionMessage Removed Pin
24-Jul-09 9:48
professionalN_tro_P24-Jul-09 9:48 
AnswerMessage Removed Pin
24-Jul-09 9:49
professionalN_tro_P24-Jul-09 9:49 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 9:57
Ian Shlasko24-Jul-09 9:57 
GeneralMessage Removed Pin
24-Jul-09 10:06
professionalN_tro_P24-Jul-09 10:06 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:24
Ian Shlasko24-Jul-09 10:24 
Sure... Here's the quick and dirty on both...

Dependency Property = Just a property on a class that automatically updates data binding (At the cost of a little overhead)

Attached Dependency Property = A property that goes down the tree. Think of DockPanel.Dock. It's made so child controls can have a value, but the parent stores them and can act on them. It's most similar to the old ExtenderProviders from WinForms.


As for the binding... Data binding is actually one of the more annoying parts of WPF, but it's great once you get it right. I still have to use references pretty often for the more complicated binding sources...

Every control has what's called a DataContext. This is just any old object you assign to it. It's the source for any data binding. So if you say "{Binding IsValidNewSet}", the first place it will look is in the button's DataContext property. Since it doesn't have one, it'll crawl up the tree and check the Grid's DataContext (Also missing), then the Window's DataContext... It doesn't find one, so you'll have problems.

Now, you COULD set the window's datacontext to itself in the code-behind, so the button would eventually see the Window as its datacontext and get the IsValidNewSet property. It's not the best way though...

The simplest way is to bind by name. Give the window a name in XAML, for example "MyWindow". Then use this binding for the button:
IsEnabled="{Binding ElementName=MyWindow,Path=IsValidNewSet}"

Come to think of it, I was going to post the code for a FindAncestor call, but that might be overkill... I'd say just use ElementName. This overrides the normal behavior and looks at a named element instead of the DataContext.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralMessage Removed Pin
24-Jul-09 10:36
professionalN_tro_P24-Jul-09 10:36 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:42
Ian Shlasko24-Jul-09 10:42 
GeneralMessage Removed Pin
24-Jul-09 10:46
professionalN_tro_P24-Jul-09 10:46 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:51
Ian Shlasko24-Jul-09 10:51 
GeneralMessage Removed Pin
24-Jul-09 10:19
professionalN_tro_P24-Jul-09 10:19 
GeneralRe: Binding IsEnabled of a button Pin
Ian Shlasko24-Jul-09 10:28
Ian Shlasko24-Jul-09 10:28 
AnswerRe: Binding IsEnabled of a button Pin
Pete O'Hanlon24-Jul-09 11:07
mvePete O'Hanlon24-Jul-09 11:07 
QuestionMessage Removed Pin
24-Jul-09 3:58
professionalN_tro_P24-Jul-09 3:58 
Questionsilverlight 3 Pin
wolfbinary24-Jul-09 3:36
wolfbinary24-Jul-09 3:36 
AnswerRe: silverlight 3 Pin
Pete O'Hanlon24-Jul-09 4:34
mvePete O'Hanlon24-Jul-09 4:34 
GeneralRe: silverlight 3 Pin
wolfbinary24-Jul-09 6:22
wolfbinary24-Jul-09 6:22 
GeneralRe: silverlight 3 Pin
Mark Salsbery24-Jul-09 11:08
Mark Salsbery24-Jul-09 11:08 
QuestionHosting MS Office in WPF app Pin
amit_198624-Jul-09 1:41
amit_198624-Jul-09 1:41 
AnswerRe: Hosting MS Office in WPF app Pin
Pete O'Hanlon24-Jul-09 2:18
mvePete O'Hanlon24-Jul-09 2:18 
QuestionUsing directional keys to rotate a 3D model? Pin
Etienne_12323-Jul-09 7:02
Etienne_12323-Jul-09 7:02 
AnswerRe: Using directional keys to rotate a 3D model? Pin
Pete O'Hanlon24-Jul-09 0:46
mvePete O'Hanlon24-Jul-09 0:46 
Questionconversion of Web rendering units to Wpf rendering units Pin
vsaratkar23-Jul-09 7:00
vsaratkar23-Jul-09 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.