blog about enhanced ComboBox; propertystatus interaction

blog about enhanced ComboBox; propertystatus interaction

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


davido_xml posted on Friday, April 03, 2009

Ricky,

I am trying out the comboBox code from your blog post.

I used to have:

<Grid DataContext="{StaticResource ExpenseData}">....

<ComboBox

x:Name="cboClassification"

ItemsSource="{Binding Source={StaticResource ClassificationsData}, Path=Data}"

SelectedItem="{Binding Path=Data.ClassificationId, Converter={StaticResource ClassificationsConverter}, ConverterParameter={StaticResource ClassificationsData}, Mode=TwoWay}">

</ComboBox>

<csla:PropertyStatus

RelativeTargetName="cboClassification"

Property="ClassificationId"

Source="{Binding Path=Data}"

HorizontalAlignment="Left" />

And that worked. I tried

<enhanced:ComboBox

x:Name="cboClassification"

Style="{StaticResource ComboBoxStyle}"

ItemsSource="{Binding Source={StaticResource ClassificationsData},Path=Data}"

SelectedValue="{Binding Path=ClassificationId, Mode=TwoWay}"

ValueMemberPath="Key"

DisplayMemberPath="Value"/>

But the PropertyStatus control stopped working. Any ideas?

RockfordLhotka replied on Friday, April 03, 2009

I don't know - what do you mean "stopped working"? The authz parts, or the validation parts?

In any case, your binding expressions seem out of sync. From the PropertyStatus control it appears that your container control is bound to the CslaDataProvider, but not to its Data property:

Source="{Binding Path=Data}"

Then in your extended:ComboBox your SelectedValue binding expression seems to assume that the container has already handled the Data property indirection:

SelectedValue="{Binding Path=ClassificationId, Mode=TwoWay}"

Personally, I try to have the container do the indirection on the Data property, so my actual controls just interact with the business object. This is more comparable to the normal WPF behavior, and makes my XAML more portable between SL and WPF.

davido_xml replied on Friday, April 03, 2009

Thanks. No problem with your code just me. I bet you get that alot:)

Great not to have to write lots of converters.

For others

<Grid DataContext="{Binding Source={StaticResource ExpenseData},Path=Data}">....

<enhanced:ComboBox x:Name="cboClassification" Style="{StaticResource ComboBoxStyle}"

ItemsSource="{Binding Source={StaticResource ClassificationsData},Path=Data}"

SelectedValue="{Binding Path=ClassificationId, Mode=TwoWay}"

ValueMemberPath="Key"

DisplayMemberPath="Value"/>

<csla:PropertyStatus RelativeTargetName="cboClassification" Property="ClassificationId"

Source="{Binding}" HorizontalAlignment="Left" />

Copyright (c) Marimer LLC