Hey guys please help me here. Im using a converter to bind to an enumeration with a three state checkbox. I have a 3 value enumeration, Allowed, Denied, and Unassigned. I have a custom styled checkbox that is red, green, and yellowe depending on the bound value of the enumeration. However I cannot get this to update the property on my bound object when i change the value of the checkbox. The very weird thing is I can get it to work (which is not an option i can use). If I dont use a celleditor template and just define a cellcontent template, then the editor by default is a text value -- if i type in the enumeration and hit enter or click on another row to call EndEdit then i can see the changes reflected in my business objects bound PrivilegeStatus property. However (and ive tried like 5 different combinations or things) when I define a celleditor template with a checkbox then the property is never updated after the EndEdit. Very strange. Ive also looked at changing the return values for my ConvertBack function in my converter, to no avail. I will past the code for my converter and then for my datatemplates. Someone here please help! :)
This is the setup where I can edit the text and type in the correct enum value and it works, but this is not an option i can take.
<xcdg:Column Title="Privilege Status" FieldName="UserPrivilegeStatus" ReadOnly="False" >
<xcdg:Column.CellContentTemplate>
<DataTemplate>
<CheckBox Style="{DynamicResource PrivilegeCheckbox}" IsThreeState="True" IsChecked="{Binding Path=.,Converter={StaticResource StatusConverter},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</xcdg:Column.CellContentTemplate>
<!--<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<CheckBox Style="{DynamicResource PrivilegeCheckbox}" IsThreeState="True" IsChecked="{Binding Path=.,Converter={StaticResource StatusConverter},Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>-->
</xcdg:Column>
Heres my converter code
Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
If (value IsNot Nothing) And (CType(value, String) <> "") Then
Dim status As Common.Enums.PrivilegeStatus = CType(value, Common.Enums.PrivilegeStatus)
Select Case status
Case Common.Enums.PrivilegeStatus.Allowed
Return True
Case Common.Enums.PrivilegeStatus.Denied
Return False
Case Common.Enums.PrivilegeStatus.Unassigned
Return Nothing
Case Else
Return Nothing
End Select
Else
Return Nothing
End If
End Function
Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.ConvertBack
If value Is Nothing Then
Return Common.Enums.PrivilegeStatus.Unassigned
Else
If CType(value, Boolean) = False Then
Return Common.Enums.PrivilegeStatus.Denied
Else
Return Common.Enums.PrivilegeStatus.Allowed
End If
End If
Throw New Exception("Cannot convert back")
End Function
Any help is greatly appreciated!
Thanks
Justin Coon