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

RadTimeSelector nested in a RadModalWindow fires an ArgumentException

5 Answers 46 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
MM
Top achievements
Rank 1
MM asked on 25 Feb 2014, 01:41 PM
I'm trying to put a RadTimeSelector in a RadModalWindow where I manipulate the IsOpen property via DataBinding.

Like this:
<telerikPrimitives:RadWindow Grid.Row="1" IsOpen="{Binding PickReminderTime, Mode=TwoWay}" Placement="CenterCenter">
    <telerikInput:RadTimeSelector SelectorFormat="h/m" SelectedValue="{Binding ReminderEditTime,Mode=TwoWay}"/>
</telerikPrimitives:RadWindow>


Important I've got this RadWindow (tried RadModalWindow as well) in a second page. And when I navigate to this second page the first time it seems to work. Even manipulating the IsOpen property multiple times, it's still working. However when I navigate back, and navigate to this secondpage again (with a different uri parameter). I'm getting an ArgumentException when I manipulate the IsOpen property to be true, with the following stacktrace.

System.ArgumentException: Value does not fall within the expected range.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
   at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at Telerik.Windows.Controls.RadWindow.AddCanvas(Panel parent)
   at Telerik.Windows.Controls.RadWindow.OpenCore(Panel ancestor)
   at Telerik.Windows.Controls.RadWindow.Open()
   at Telerik.Windows.Controls.RadWindow.SyncOpenState()
   at Telerik.Windows.Controls.RadWindow.OnIsOpenChanged(Boolean newValue, Boolean oldValue)
   at Telerik.Windows.Controls.RadWindow.OnIsOpenChanged(Object sender, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
   at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
   at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
   at System.Windows.Data.BindingExpression.SendDataToTarget()
   at System.Windows.Data.BindingExpression.SourcePropertyChanged(PropertyPathListener sender, PropertyPathChangedEventArgs args)
   at System.Windows.PropertyPathListener.RaisePropertyPathStepChanged(PropertyPathStep source)
   at System.Windows.PropertyAccessPathStep.RaisePropertyPathStepChanged(PropertyListener source)
   at System.Windows.CLRPropertyListener.SourcePropertyChanged(Object sender, PropertyChangedEventArgs args)
   at System.Windows.Data.WeakPropertyChangedListener.PropertyChangedCallback(Object sender, PropertyChangedEventArgs args)
   at System.ComponentModel.PropertyChangedEventHandler.Invoke(Object sender, PropertyChangedEventArgs e)
   at GalaSoft.MvvmLight.ObservableObject.RaisePropertyChanged(String propertyName)
   at MC.Chain.WPUI.ViewModel.ViewModelBase.RaisePropertyChanged(String propertyName)
   at MC.Chain.WPUI.ViewModel.EditGoalViewModel.set_PickReminderTime(Boolean value)
   at MC.Chain.WPUI.ViewModel.EditGoalViewModel.PickReminder()
   at GalaSoft.MvvmLight.Helpers.WeakAction.Execute()
   at GalaSoft.MvvmLight.Command.RelayCommand.Execute(Object parameter)
   at System.Windows.Controls.Primitives.ButtonBase.ExecuteCommand()
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)


I tried using the RadWindow with different content first, and Isolated that the RadTimeSelector doesn't like being displayed a second time.

Is there a workaround? I want to achieve a UI like the attached screenshot.

5 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 28 Feb 2014, 08:03 AM
Hi Mark,

Based on your description I guess the second time your app goes into an invalid state where the content of the windows is inserted into the frame without being removed before that.

However, without being able to directly debug your code I cannot be sure that this is the reason for the exception. Can you please share with us your project in a separate support thread and we will make sure to see what goes wrong?

Regards,
Deyan
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
0
MM
Top achievements
Rank 1
answered on 28 Feb 2014, 11:57 AM
Hi Deyan,

I've added the code to the ticket I created: 792882

Hope this helps.

Best,

Mark Monster
0
Deyan
Telerik team
answered on 28 Feb 2014, 02:18 PM
Hi Mark,

Thanks for writing.

The reason for the exception is the binding to the IsOpen property. The static MainViewModel keeps a reference to the RadWindow instance and thus it can never be garbage collected. RadWindow itself contains a static Canvas object which is used to represent the content of the window when it's opened. Once RadWindow is shown, the Canvas becomes part of the visual tree. This creates a given state which later, when showing the window for a second time causes the ArgumentException.

The quick fix for this is to omit the binding of the IsOpen property until we find out the exact reason for the undesired behavior and see what we can do about it.

Regards,
Deyan
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
0
MM
Top achievements
Rank 1
answered on 28 Feb 2014, 02:32 PM
Interesting, but what happens when any of the content in the Window gets databound. Will that also cause the same problem? I'm willing to do some parts inside the Code Behind as an alternative.
0
Deyan
Telerik team
answered on 04 Mar 2014, 01:01 PM
Hello Mark,

After performing some further investigations, I think the reason for the undesired behavior is that you are directly putting visual elements within the Content property of the Window. Can you please try using the standard Silverlight pattern by binding the Content property of the Window to your data context and defining a ContentTemplate where your visual elements will reside. There you can bind them to your data context accordingly.

Let us know how this approach works for you.

Regards,
Deyan
Telerik
If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
Tags
Window
Asked by
MM
Top achievements
Rank 1
Answers by
Deyan
Telerik team
MM
Top achievements
Rank 1
Share this question
or