Hello I've a RadGridView that is placed withing a RadWindow and wrapped within an UserControl.
The RadWindow will be initialized by an ContextMenu of a parent RadGridView (selected item) please see the code snippets below.
Code from the ContextMenu to open a new RadWindow:
XAML of the UserControl:
Code of the ViewModel
I come here not further...
How can i put the two required values ​​SelectedItemID and SelectedItemTypeID to the ViewModel, so that they can be used when the DataBinding request the the Entries?
I'll hold this 2 values inside the ContextMenu "tmpItem" (e.g. tmpItem.ID and tmpItem.Type) but i've no idea how i could put that throuth the UserControl and ViewModel.
I think I am using the wrong approach... hopefully someone could give me an idea how to solve this issue.
Any help on this would be very welcome!
Kind regards
Daniel
The RadWindow will be initialized by an ContextMenu of a parent RadGridView (selected item) please see the code snippets below.
Code from the ContextMenu to open a new RadWindow:
var tmpItem = row.Item
as
ItemModel;
.....
case
"ViewRelatedItems"
:
if
( tmpItem !=
null
)
{
RadWindow radWindow =
new
RadWindow();
radWindow.Width = 510;
radWindow.Height = 350;
UserControlRelatedItemsEntries ucTmp =
new
UserControlRelatedItemsEntries(tmpItem.ID, tmpItem.Type);
radWindow.Content = ucTmp;
radWindow.Owner = Application.Current.MainWindow;
radWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
radWindow.ResizeMode = ResizeMode.NoResize;
radWindow.Header =
"Entries:"
;
//TODO
radWindow.Show();
}
break
;
XAML of the UserControl:
<UserControl x:Class=
"TEST..UserControlViewEntries"
xmlns:sys=
"clr-namespace:System;assembly=mscorlib"
xmlns:telerik=
"http://schemas.telerik.com/2008/xaml/presentation"
xmlns:viewModel=
"clr-namespace:test.ViewModels;assembly=Test.ViewModels"
mc:Ignorable=
"d"
d:DesignHeight=
"300"
d:DesignWidth=
"500"
>
<UserControl.DataContext>
<viewModel:MyViewModel />
</UserControl.DataContext>
<Grid>
<telerik:RadGridView x:Name=
"radGridEntries"
Margin=
"0,30,0,0"
ItemsSource=
"{Binding Entries}"
AutoGenerateColumns=
"False"
DataLoadMode=
"Asynchronous"
>
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding UserName}"
Header=
"User"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Date}"
Header=
"Date"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding XDoneAsString}"
Header=
"XDone"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Description}"
Header=
"Description"
/>
<telerik:GridViewDataColumn DataMemberBinding=
"{Binding Type}"
Header=
"Type"
/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</UserControl>
Code of the ViewModel
public
class
MyViewModel : ObservableObjectBase
{
#region Properties
public
int
SelectedItemID {
get
;
set
; }
public
int
SelectedItemTypeID {
get
;
set
; }
private
ObservableCollection<XModel> _items;
public
ObservableCollection<XModel> Entries
{
get
{
if
( _items ==
null
)
{
_items =
new
ObservableCollection<XModel>();
var tmpResults = DataService.GetItems(
this
.SelectedItemID,
this
.SelectedItemTypeID);
tmpResults.ForEach( i => _items.Add( i ) );
}
return
_items;
}
}
#endregion
#region Methods
#endregion
#region Constructors
public
MyViewModel ()
{ }
#endregion
}
I come here not further...
How can i put the two required values ​​SelectedItemID and SelectedItemTypeID to the ViewModel, so that they can be used when the DataBinding request the the Entries?
I'll hold this 2 values inside the ContextMenu "tmpItem" (e.g. tmpItem.ID and tmpItem.Type) but i've no idea how i could put that throuth the UserControl and ViewModel.
I think I am using the wrong approach... hopefully someone could give me an idea how to solve this issue.
Any help on this would be very welcome!
Kind regards
Daniel