ShowDialog - MVVM

4 posts, 0 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    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?
  2. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 08 Nov 2012 Link to this post

    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.

  3. DevCraft banner
  4. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 12 Nov 2012 Link to this post

    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




  5. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 Nov 2012 Link to this post

    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.

Back to Top