I have this class
this ViewModel
I initialize my App
How can I view the groups by tags "Tag 1", "Tag 2", "Tag 3", "Tag 4" in a RadGridView?
In m_ViewModelMainWindows.MyListOfObject I have 4 groups, but in RadGridView of MainWindow I have 3 groups of list.
The MainWindow.xaml is
Best regards
Riccardo
public
class
myObject
{
public
String Name {
get
;
set
; }
public
List<String> Tags{
get
;
set
;}
}
public
class
ViewModelMainWindow:ViewModel
{
System.ComponentModel.ICollectionView m_myListOfObject;
public
ICollectionView MyListOfObject
{
get
{
return
m_myListOfObject; }
set
{ m_myListOfObject = value; }
}
}
public
partial
class
App : Application
{
MainWindow m_ViewMainWindow;
ViewModelMainWindow m_ViewModelMainWindows;
List<myObject> m_myListOfObject;
protected
override
void
OnStartup(StartupEventArgs e)
{
Init();
m_ViewMainWindow.Show();
}
void
Init()
{
m_ViewMainWindow =
new
MainWindow();
m_ViewModelMainWindows =
new
ViewModelMainWindow();
PropertyGroupDescription groupDescriptionPorte =
new
PropertyGroupDescription(
"Tags"
);
m_myListOfObject =
new
List<myObject>();
m_myListOfObject.Add(
new
myObject());
m_myListOfObject.Last().Name =
"Element 1"
;
m_myListOfObject.Last().Tags =
new
List<
string
>();
m_myListOfObject.Last().Tags.Add(
"Tag 1"
);
m_myListOfObject.Last().Tags.Add(
"Tag 2"
);
m_myListOfObject.Add(
new
myObject());
m_myListOfObject.Last().Name =
"Element 2"
;
m_myListOfObject.Last().Tags =
new
List<
string
>();
m_myListOfObject.Last().Tags.Add(
"Tag 1"
);
m_myListOfObject.Last().Tags.Add(
"Tag 3"
);
m_myListOfObject.Add(
new
myObject());
m_myListOfObject.Last().Name =
"Element 3"
;
m_myListOfObject.Last().Tags =
new
List<
string
>();
m_myListOfObject.Last().Tags.Add(
"Tag 2"
);
m_myListOfObject.Last().Tags.Add(
"Tag 4"
);
m_ViewModelMainWindows.MyListOfObject = CollectionViewSource.GetDefaultView(m_myListOfObject);
m_ViewModelMainWindows.MyListOfObject.GroupDescriptions.Add(groupDescriptionPorte);
m_ViewMainWindow.DataContext = m_ViewModelMainWindows;
}
}
How can I view the groups by tags "Tag 1", "Tag 2", "Tag 3", "Tag 4" in a RadGridView?
In m_ViewModelMainWindows.MyListOfObject I have 4 groups, but in RadGridView of MainWindow I have 3 groups of list.
The MainWindow.xaml is
<
Window
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
x:Class
=
"grouping_by_tags.MainWindow"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"137*"
/>
<
RowDefinition
Height
=
"183*"
/>
</
Grid.RowDefinitions
>
<
telerik:RadGridView
HorizontalAlignment
=
"Left"
Height
=
"320"
VerticalAlignment
=
"Top"
Width
=
"517"
ItemsSource
=
"{Binding MyListOfObject}"
Grid.RowSpan
=
"2"
/>
</
Grid
>
</
Window
>
Best regards
Riccardo