-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on comiling #1
Comments
It sounds like you're embedding a GroupedObservableCollection directly in XAML, rather than binding one to a CollectionViewSource? Could you post the XAML that's giving the error? |
Hm...actually i tried to add it from code Behind //Favorites is an ObservableCollection<Manga>
public GroupedObservableCollection<char, Manga> FavoritesGroups = new GroupedObservableCollection<char, Manga>(m => m.Title[0], Favorites);
private CollectionViewSource _favoritesCVS;
public CollectionViewSource FavoritesCVS
{
get { return _favoritesCVS = _favoritesCVS ?? new CollectionViewSource() { IsSourceGrouped = true, Source = FavoritesGroups }; }
set { Set(ref _favoritesCVS, value); }
} in XAML i'm Binding it like this <GridView x:Name="ZoomedInGridView"
ItemsSource="{x:Bind ViewModel.FavoritsCVS.View, Mode=OneWay}"
...more stuff... >
<GridView.GroupStyle>
<GroupStyle HidesIfEmpty="True">
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="utils:Grouping">
<TextBlock Text="{x:Bind Key}" Margin="0,0,0,-10"
Style="{ThemeResource SubheaderTextBlockStyle}"
Foreground="{ThemeResource SystemControlHighlightAccentBrush}"/>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</GridView.GroupStyle>
</GridView> I hope this helps. Do you also need the "Manga"-Model? |
Hi, sorry for the delay - it looks like you're binding your Does that help? |
Got it working, thank you for the help. |
ok, i was wrong. it's still there. when i get the GroupedObservableCollection from a Helper/Service as a Property and use that Property as a Source for the CVS i get the error. public GroupedObservableCollection<char, Manga> FavoritesGroups { get { return _library.Favorites; } }
private CollectionViewSource _favoritesCVS;
public CollectionViewSource FavoritesCVS
{
get { return _favoritesCVS = _favoritesCVS ?? new CollectionViewSource() { IsSourceGrouped = true, Source = FavoritesGroups }; }
set { Set(ref _favoritesCVS, value); }
} when i change the code like this private CollectionViewSource _favoritesCVS;
public CollectionViewSource FavoritesCVS
{
get { return _favoritesCVS = _favoritesCVS ?? new CollectionViewSource() { IsSourceGrouped = true, Source = new GroupedObservableCollection<char,Manga>(m => m.Title[0], Favorites) }; }
set { Set(ref _favoritesCVS, value); }
}
//Favorites is an ObservableCollection<Manga> it works. Do you have any idea why that is? |
Hi Mike,
i tried to implement and use your GroupedObservableCollection, but on compiling i got the following error
Cannot determine the item type of collection type 'MangaReader_MVVM.Utils.GroupedObservableCollection'2[System.char,MangaReader_MVVM.Models.Manga]' because it has more than one Add method or ICollection<T> implementation. To make this collection type usable in XAML, add a public Add(object) method, implement System.Collections.IList or a single System.Collections.Generic.ICollection<T>.
and i don't know where this other Add method should be.I didn't change anything of your code, just used it...so...do you maybe have an idea?
The text was updated successfully, but these errors were encountered: