I have a combobox for the status property of the object. It contains Open/Closed. When the object is closed, none of the properties of the object should be editable, except status. Once status is changed back to Open, all the properties should then be editable. This worked fine in WinForms, but to get it to work in wpf, I had to make a change at the top of the SetWrite method of the Authorizer
bool canWrite = source.CanWriteProperty(bnd.Path.Path); VisibilityMode visibilityMode = GetNotVisibleMode(ctl); if (visibilityMode == VisibilityMode.Ignore)canWrite =
true;With this change, it works.
What does CanWriteProperty(“Status”) return when the
object is closed? It must return true right? You’ve overridden
CanWriteProperty() to return false for all other properties based on the status
value?
I guess I still don’t understand what’s happening in
the app. For the property to be writable, CanWriteProperty() should be
returning true – and then Authorizer would turn on the control (or wouldn’t
turn it off in this case).
Rocky
From: Curelom
[mailto:cslanet@lhotka.net]
Sent: Wednesday, September 12, 2007 4:55 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] WPF Authorization - ApplyAuthorization on
ReadWriteAuthorization
I have a combobox for the status property of the object. It contains
Open/Closed. When the object is closed, none of the properties of the
object should be editable, except status. Once status is changed back to
Open, all the properties should then be editable. This worked fine in
WinForms, but to get it to work in wpf, I had to make a change at the top of
the SetWrite method of the Authorizer
bool canWrite = source.CanWriteProperty(bnd.Path.Path);
VisibilityMode visibilityMode = GetNotVisibleMode(ctl);
if (visibilityMode == VisibilityMode.Ignore)
canWrite = true;
With this change, it works.
I did overwrite the CanWriteProperty.
public override bool CanWriteProperty(string propertyName) {
if (!this.IsTicketBeingClosed() && this.Status == "Closed"
&& propertyName !=
"Status") return false; else return base.CanWriteProperty(propertyName);}
The control I am working with is below. Debugging, it is going through the SetWrite method twice, once where bnd.Path.Path has a value of Status, the other time it is going through where bnd.Path.Path is an empty string, and that is where CanWriteProperty returns false. I have no idea where it is coming up with the second empty binding. I've noticed it does this for each of my comboboxes. Am I binding them correctly? There is a grid control with the list of objects, and a detail tabcontrol below it. In the tabcontrol I'm setting the DataContext like this
DataContext
="{Binding Path=CurrentItem, ElementName=TicketGrid}"The grid is populated via CslaDataProvider and the ItemsSource of the comboboxes are also populated via CslaDataProvider
<ComboBox ItemsSource="{Binding Source={StaticResource ticketStatusList}}"
DisplayMemberPath="CallStatus" MaxWidth="100" SelectedValuePath="CallStatus" SelectedValue="{Binding Path=Status}" Width="Auto" Margin="0,0,0,0" Canvas.Left="240" Canvas.Top="83" x:Name="cmbStatus" Height="22" />Maybe you have found a bug in how the control walks through the
visual tree. I’ll have to try and replicate the issue.
Rocky
From: Curelom
[mailto:cslanet@lhotka.net]
Sent: Wednesday, September 12, 2007 6:35 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RE: WPF Authorization - ApplyAuthorization on
ReadWriteAuthorization
I did overwrite the CanWriteProperty.
public override bool CanWriteProperty(string
propertyName) {
if (!this.IsTicketBeingClosed()
&& this.Status == "Closed"
&& propertyName != "Status")
return false;
else
return base.CanWriteProperty(propertyName);
}
The control I am working with is below.
Debugging, it is going through the SetWrite method twice, once where
bnd.Path.Path has a value of Status, the other time it is going through where
bnd.Path.Path is an empty string, and that is where CanWriteProperty returns
false. I have no idea where it is coming up with the second empty
binding. I've noticed it does this for each of my comboboxes. Am I
binding them correctly? There is a grid control with the list of objects,
and a detail tabcontrol below it. In the tabcontrol I'm setting the
DataContext like this
DataContext="{Binding Path=CurrentItem, ElementName=TicketGrid}"
The grid is populated via
CslaDataProvider and the ItemsSource of the comboboxes are also populated via
CslaDataProvider
<ComboBox ItemsSource="{Binding Source={StaticResource ticketStatusList}}"
DisplayMemberPath="CallStatus" MaxWidth="100"
SelectedValuePath="CallStatus"
SelectedValue="{Binding Path=Status}"
Width="Auto" Margin="0,0,0,0" Canvas.Left="240" Canvas.Top="83" x:Name="cmbStatus" Height="22" />
Copyright (c) Marimer LLC