I\'ve been reading about this at least for 4 hours, and seems to be the list type, but I have a situation:
A ObservableCollection that has a collection property.
Tks to @nit who give me the right path. Of course the problem reside on the base Type of EF collections
Hashet< T > And Datagrid need at least a List< T >, changing all my classes "those generated by Entity framework", give to me another problem, must make changes manually, and I have a lot of them.
My solution was to create a converter, that made the dirty work for me:
public class listToObservableCollection : BaseConverter, IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
HashSet observableList = (HashSet)value;
return new ObservableCollection(observableList);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return (HashSet)value;
}
}
public abstract class BaseConverter : MarkupExtension
{
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
And put it on the binding of my Datagrid2:
xmlns:l="clr-namespace:Recursos;assembly=Recursos"
...
...
ItemsSource="{Binding Level2,Converter={StaticResource listoToObservable}}"
The only thing on the air is how to make a generic converter, but for now it works fine.