IsSavable, INotifyPropertyChanged and WPF binding

IsSavable, INotifyPropertyChanged and WPF binding

Old forum URL: forums.lhotka.net/forums/t/2548.aspx


FreeAsInBeer posted on Monday, March 19, 2007

hi all,

I was trying to bind my CSLA object's IsSavable property to the IsEnabled property on a button, like this;

<Button Click="SavePerson" Width="150" IsEnabled="{Binding Path=IsSavable, Mode=OneWay}">Save changes</Button>


However it looks like the base IsSavable doesnt implement INotifyPropertyChanged. I thought it did. Have I misread something in the code?

In debugging IsSavable/IsDirty changes as I edit a property, but this change is not updated in the above binding.

any thoughts?

tar
FaiB



RockfordLhotka replied on Monday, March 19, 2007

The Is___ properties are marked as Browsable(false), which makes them unavailable for data binding.

For Windows Forms there's a perfectly good answer to this issue.

For WPF I've got a prototype answer in CSLA .NET 3.0. See this blog post and the CSLA .NET 3.0 change log for details.

If you want to experiment and/or help test, you can get the current CSLA .NET 3.0 code direct from my svn repository. Also, I'm speaking on this at VS Live this coming Sunday, and I'll be putting whatever code is current online prior to teaching that workshop. That'll be at www.lhotka.net/cslanet/download.aspx.

FreeAsInBeer replied on Monday, March 19, 2007

ah, thanks. I'd noticed the Browsable(false) attribute, but was not fully aware of what it did.

I'd love to experiment and/or test CSLA 3.0, but this will have to wait a few weeks. I'm in the middle of doing my first sample WPF app, which is also my first CSLA app, and don't want to introduce a 3rd spanner :)


RockfordLhotka replied on Monday, March 19, 2007

I fully understand about introducing unknowns into your app. But if you are even trying to use CSLA behind WPF, I really think you want the experimental CSLA .NET 3.0 stuff.

 

CslaDataProvider: a data provider control that works with CSLA objects

 

ValidationPanel: provides ErrorProvider-like behaviors in your WPF form

 

AuthorizationPanel: provides ReadWriteAuthorization-like behaviors in your WPF form

 

ObjectStatusPanel: exposes the Is___ properties for binding in your form

 

Without these new controls you won’t be able to get validation or authorization behaviors, or to use the Is___ properties. WPF simply doesn’t offer the capabilities of Windows Forms in terms of validation or bindingsource events, so there are no simple workarounds to do what these new Csla.Wpf controls are doing. (I’ve no doubt that a future version of WPF will at least include an ErrorProvider equivalent – that’s too important for them to ignore for WPF 2.0 – but in the intervening months or years, we need something…)

 

The CslaDataProvider is purely optional, as you can always set the DataContext through code. But it does offer async loading of data without you having to mess with threading yourself, and that can be nice.

 

Rocky

 

 

From: FreeAsInBeer [mailto:cslanet@lhotka.net]
Sent: Monday, March 19, 2007 10:05 AM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] IsSavable, INotifyPropertyChanged and WPF binding

 

ah, thanks. I'd noticed the Browsable(false) attribute, but was not fully aware of what it did.

I'd love to experiment and/or test CSLA 3.0, but this will have to wait a few weeks. I'm in the middle of doing my first sample WPF app, which is also my first CSLA app, and don't want to introduce a 3rd spanner :)




Copyright (c) Marimer LLC