Hello,
Currently I am working on converting a ComboBox into a XamMultiColumnComboEditor as I'm trying to enhance the functionality of a drop down to include more information per item.
The ComboBox in question looks like this:
<ComboBox Name="BankAccounts" Visibility="{Binding ShowAllPaymentFields, Converter = {StaticResource BooleanToVisibilityConverter}}" ItemsSource="{Binding Path=BankAccounts}" SelectedItem="{Binding CurrentPayment.BankAccount,Mode=TwoWay}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Converter={StaticResource BankAccountDisplayConverter}}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
I have started on the XamMultiColumnComboEditor and this is what it looks like:
<ig:XamMultiColumnComboEditor x:Name="BankAccounts" Visibility="{Binding ShowAllPaymentFields, Converter = {StaticResource BooleanToVisibilityConverter}}" MinDropDownHeight="100" MinDropDownWidth="230" ItemsSource="{Binding Path=BankAccounts}" AutoGenerateColumns="False" DisplayMemberPath="AccountNumber" SelectedItem="{Binding CurrentPayment.BankAccount,Mode=TwoWay}"> <ig:XamMultiColumnComboEditor.Columns> <ig:TextComboColumn Key="AccountNumber"/> <ig:TextComboColumn Key="BankName"/> <ig:DateComboColumn Key="DateLastUsed"/> </ig:XamMultiColumnComboEditor.Columns> </ig:XamMultiColumnComboEditor>
My issue is that I do not know how to add the BankAccountDisplayConverter from the ComboBox above into the XamMultiColumnComboEditor. Does anyone have any insight on how to do this? Please let me know if you need clarification.
Thanks,
Alex
Hello Alex,
Thank you for the code snippet, you have sent.
You have set three columns for the XamMultiColumnComboEditor. Can you sent also the BankAccountDisplayConverter code?If you want to set a converter in a specific column, you can use ValueConverter property:<ig:TextComboColumn Key="BankName" ValueConverter="{StaticResource myConverter}"/>
Thank you, although that is the correct way to do it, now I'm facing type conversion issues in the Converter which you requested so I'll give you a code snippet of that:
class BankAccountDisplayConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null && value !="") { var bankAccount = (BankAccount) value; var canSeeAllDigits = App.CurrentPaymentSession.CurrentCollectionRep.CanSeeAllDigitsOnBankAccounts == 1; var displayString =bankAccount.GetDisplayString(canSeeAllDigits); return displayString; } else { return ""; } }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return value; } }}
The converter expects a BankAccount object to get passed into "value" and instead the AccountNumber string gets passed in which causes a cast exception. Any way you know of remedying this and passing in the object itself rather than the AccountNumber string?