Hello,
I've searched the forum but without success! Apparently, I am the only one trying to bind a GridViewComboBoxColumn to a class (instead of simple a int or a string).
All the binding is working fine, the ComboBox is filled in correctly, changing and saving data is working but the GridView doesn't display the value on start (strangely, it is displaying correctly after I choose a value in the ComboBox...)!
I guess there is something missing to make the match between the original value and the values in the ComboBox... but what?
Here is a sample of my faulty code:
The main class of the GridView (note that here we have a Currency class and not a CurrencyID)
The Currency class
The grid's XAML code
The .cs code behind where currencies are taken from the DB.
Any idea why with this code, the Currency column appears empty on load (while Fund.Currency is correctly filled in on start)?
Thank you,
Daniel
I've searched the forum but without success! Apparently, I am the only one trying to bind a GridViewComboBoxColumn to a class (instead of simple a int or a string).
All the binding is working fine, the ComboBox is filled in correctly, changing and saving data is working but the GridView doesn't display the value on start (strangely, it is displaying correctly after I choose a value in the ComboBox...)!
I guess there is something missing to make the match between the original value and the values in the ComboBox... but what?
Here is a sample of my faulty code:
The main class of the GridView (note that here we have a Currency class and not a CurrencyID)
public class Fund |
{ |
public virtual string Name { get; set; } |
public virtual Currency Currency { get; set; } |
} |
The Currency class
public class Currency : AbstractLinkedClass |
{ |
public virtual string IsoCode { get; set; } |
} |
The grid's XAML code
<telerik:RadGridView Grid.Row="3" Margin="0,5,0,5" Name="rgvFund" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" AutoGenerateColumns="False" RowEditEnded="rgvFund_RowEditEnded" ValidationMode="Row"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn Header="Name" DataMemberPath="Name" /> |
<telerik:GridViewComboBoxColumn Header="Currency" ItemsSource="{Binding}" UniqueName="Currency.IsoCode" DataMemberBinding="{Binding Currency}" DisplayMemberPath="IsoCode" SelectedValueMemberPath="." /> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
The .cs code behind where currencies are taken from the DB.
rgvFund.Columns[1].DataContext = currencies; |
Any idea why with this code, the Currency column appears empty on load (while Fund.Currency is correctly filled in on start)?
Thank you,
Daniel