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

XAML-SDK Reminders example little bug

2 Answers 50 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Iron
Richard asked on 24 Aug 2017, 05:37 PM

For what it worth, playing around with the reminders example I found that it wouldn't open the appointment for edition when the "Open Item"  button is clicked.

I checked the git repository to see if this is already addressed, but the last update to this files is about 4 years old, so here is the trick:

 

It turns out that at the time where the scheduleview reference is passed to the ReminderViewModel constructor (via the ViewModel class constructor), it is null.

So I added a ScheduleView property to ViewModel as a fachade for the reminder's view model property:

        public RadScheduleView ScheduleView
        {
            get { return reminderViewModel.ScheduleView; }
            set { reminderViewModel.ScheduleView = value; }
        }

and set it again once the IntializeComponent() method is called in the Example window's constructor:

        public Example()
        {
            viewModel = new ViewModel(this.scheduleView);
            this.DataContext = viewModel;
            InitializeComponent();
            viewModel.ScheduleView = this.scheduleView;
        }

And presto! Now it works as expected.

 

Best regards.

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 29 Aug 2017, 02:04 PM
Hello Richard,

Thank you for pointing this issue. Based on your feedback be fixed it and the fix will be live on GitHub pretty soon. I also updated your Telerik points as a small gratitude for reporting this. 

Just for your information, the 'scheduleView' was null because it is get before the InitializeComponent() method is called. To resolve this you can just move the ViewModel creating just after InitializeComponent().
public Example()
{  
    InitializeComponent();
    viewModel = new ViewModel(this.scheduleView);
    this.DataContext = viewModel;
}

Regards,
Martin Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Richard
Top achievements
Rank 1
Iron
answered on 30 Aug 2017, 05:13 PM

Thanks martin.

I am obviously influenced by the fact that usually I do some stuff *before* setting the view model...  Usually, I DO need the view model before initializing components because they already carry some significant info to show...

Maybe that is a call to review desing style... hmmm...

Best regards.

Tags
ScheduleView
Asked by
Richard
Top achievements
Rank 1
Iron
Answers by
Martin Ivanov
Telerik team
Richard
Top achievements
Rank 1
Iron
Share this question
or