This is a migrated thread and some comments may be shown as answers.

ShowDialog - MVVM

3 Answers 142 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tim
Top achievements
Rank 1
Tim asked on 05 Nov 2012, 06:00 PM
I'm using MVVM design pattern and trying to access ShowDialog of the RadScheduleView.
I have the following set up:
<UserControl  xmlns:viewModels="clr-namespace:Scheduler.ViewModels">
 
<UserControl.Resources>
        <viewModels:MainPageViewModel x:Key="ViewModel" />
...
</UserControl.Resources>
 
 
<telerik:RadScheduleView telerik:StyleManager.Theme="Office_Silver"
   x:Name="radScheduleView"
   Grid.Column="1"
   Grid.Row="0"
   ShowDialog="RadScheduleView_ShowDialog">

I placed RadScheduleView_ShowDialog in MainPageViewModel.cs but it cannot find it.

What do I need to do to get this working?

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Nov 2012, 09:22 AM
Hi Tim,

ShowDialog is an event, not a command and cannot be handled in the ViewModel like this. I would suggest to check our Event To Command tutorial and choose one of the approaches explained there.

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Tim
Top achievements
Rank 1
answered on 12 Nov 2012, 04:40 PM
I found an example that uses the following namespaces

instead of
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

Both use triggers but the example I found relies on creating the following in the ViewModel:
private ICommand showDialog;
private ICommand ShowDialog
{
     get
     {
          return this.showDialog;
     }
     set
     {
          this.showDialog = value;
     }
}
 
 
 
public void OnShowDialog(object sender, ShowDialogEventArgs e)
{
}

Which method is preferred? It works with this code but is not the same as the references you sent.

Thanks




0
Yana
Telerik team
answered on 14 Nov 2012, 08:48 AM
Hi Tim,

Our tutorial is just an example how to handle events in the ViewModel, it is not the only way.  As your current solution is working, there is no reason to change it.

As to the namespaces - you can find more information about XAML namespaces here.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Tim
Top achievements
Rank 1
Answers by
Yana
Telerik team
Tim
Top achievements
Rank 1
Share this question
or