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

Xaml parsing errors using the RadDock control - Support Ticket ID: 199566

3 Answers 106 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Julian
Top achievements
Rank 1
Julian asked on 24 Mar 2009, 06:08 AM

I have experienced several xaml parsing errors using the RadDock control in the RadControls for Silverlight v2009.1 312.  The errors seem to occur when a RadDock control contains a child UserControl, when the child UserControl contains certain combinations of other controls.

These errors did not occur with our code when using the previous beta version of RadControls for Silverlight 2008.3 1217.  We have only seen the errors after upgrading from the beta version to the release version.

The error seems similar to that raised in this forum by other users of the Dock control.

I have raised support Ticket ID: 199566, with an attached a zip file that contains a solution showing the defects.  The ReadMe.txt file in the zip file explains the errors and how to reproduce them.

Can you please tell me the status of this support ticket, as I have not had any acknowledgement of its receipt, and we need a fix for this issue ASAP, as we are two weeks away from a production deployment.

Thanks

Julian

3 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 24 Mar 2009, 12:23 PM
Hello Julian,

We are sorry for the long time that it takes, but we are still working on the problem and we are searching what causes the problem and how to fix or workaround it.

Kind regards,
Miroslav Nedyalkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Matthew Cartwright
Top achievements
Rank 1
answered on 31 Mar 2009, 01:27 PM
I too am experiencing a problems with very simple structures in a RadDock panel, and this may be related. My symptoms are:

Whenadding a simple split panel it work OK:

<UserControl x:Class="eg.Repro.ModuleB.Page" 

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

             xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"

    <Grid> 

        <telerikDocking:RadDocking x:Name="docking"

            <telerikDocking:RadSplitContainer InitialPosition="DockedRight"

            </telerikDocking:RadSplitContainer> 

        </telerikDocking:RadDocking> 

    </Grid> 

</UserControl> 

Whenadding a pane, as per the simple example from the CHM instructions, with asimple textblock as content:

<UserControl x:Class="eg.Repro.ModuleB.Page" 

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 

             xmlns:telerikDocking="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Docking"

    <Grid> 

        <telerikDocking:RadDocking x:Name="docking"

            <telerikDocking:RadSplitContainer InitialPosition="DockedRight"

                <telerikDocking:RadPaneGroup> 

                    <telerikDocking:RadPane Header="Testing"

                        <TextBlock Text="Text block text..." /> 

                    </telerikDocking:RadPane> 

                </telerikDocking:RadPaneGroup> 

            </telerikDocking:RadSplitContainer> 

        </telerikDocking:RadDocking> 

    </Grid> 

</UserControl> 

Iget the following error:


Microsoft JScript runtime error: Unhandled Error in Silverlight 2 Application  

Code: 4004     

Category: ManagedRuntimeError        

Message: System.ArgumentException: Value does not fall within the expected range. 

   at MS.Internal.XcpImports.CheckHResult(UInt32 hr) 

   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh) 

   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj) 

   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value) 

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle) 

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value) 

   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) 

   at System.Windows.FrameworkElement.set_DataContext(Object value) 

   at Telerik.Windows.Controls.RadTabControl.EnsureContainersAreUpdated(Int32 newIndex) 

   at Telerik.Windows.Controls.RadTabControl.OnSelectedIndexChanged(Int32 oldIndex, Int32 newIndex) 

   at Telerik.Windows.Controls.RadTabControl.OnSelectedIndexChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 

   at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e) 

   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue) 

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle) 

   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value) 

   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) 

   at Telerik.Windows.Controls.RadTabControl.set_SelectedIndex(Int32 value) 

   at Telerik.Windows.Controls.RadTabControl.OnLoaded(Object sender, RoutedEventArgs e) 

   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) 

   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)  

Ihave references to the 2009.1.312 Docking and Control dll's in my project. 


If I remove the x:Name (<telerikDocking:RadDocking x:Name="docking">)  I get a parsing error:


I have also raised a support request and eagerly await feedback.


Regards,

Mark

0
Miroslav
Telerik team
answered on 04 Apr 2009, 10:31 AM
Hi Matthew,

I answered to a support ticket regarding the same problem and I will paste my answer here, so that anyone that may experience this as well will see it:

If your ViewModel is a DependencyObject, you cannot set it as a DataContext twice, this is demonstrated by Hristo's simple example:

--------------------------------------------------------
<UserControl x:Class="SilverlightApplication1.Page"    
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300">     
    <Grid>    
        <Button DataContext="{Binding}" Content="Button1" VerticalAlignment="Top" />    
        <Button DataContext="{Binding}" Content="Button2" VerticalAlignment="Center" />    
    </Grid>    
</UserControl>    
 

and code-behind:

using System.Windows;     
using System.Windows.Controls;     
    
namespace SilverlightApplication1     
{     
    public partial class Page : UserControl     
    {     
        public Page()     
        {     
            InitializeComponent();     
            this.DataContext = new DataSource();     
        }     
    }     
    
    public class DataSource : DependencyObject     
    {     
    }     
}    
 

--------------------------------------------------------

And then my explanation for this:

I also had a look at the example and the error. The problem indeed comes from the limitation that Hristo shows, but let me expand on the problem a bit:

How is the TabControl involved?

The RadPaneGroup is actually an extended TabControl and the RadPanes are TabItems, so any issue with the TabControl is an issue with the docking.

Why is the TabControl setting the DataContext?

Our TabControl sets the DataContext of the TabItem as a DataContext to the Context Area because logically the tab item (the button) and its content are one and the same thing. This is necessary because when you want to use Databinding then you will expect that the ContentTemplate of the TabItem will have the same DataContext. Unfortunately the content area of the TabControl is not a visual ancestor of the TabItem (itself visible as just a button) so we need to set the DataContext explicitly. You may notice that other TabControls (The default one incl.) do not change the DataContext, but they also do not support Databinding.

Why is setting the Datacontext a problem?

It seems that a DependancyObject cannot be set as a DataContext twice (as demonstrated by Hristo's the simple example). This means that whatever you set as a DataContext should not derive from DependancyObject.

But you do not use Databinding in the UserControl, how is this an issue?

Even if you do not set the DataContext in this UserControl, the DataContext can be set in one of its visual parents, the main page for example. This context is then inherited by the TabItem as well, so when the RadPaneGroup selects a pane, it sets its DataContext to the content area. In this particular case, this makes no sense since the DataContext is inherited in the content area as well, but in other scenarios it does.

What to do next?

I can suggest three things:

1. Do not inherit the DependencyObject for your ViewModels.  I am not sure whether this is desirable in your case, but it may save you future headaches if you after all need to set the DataContext at more than one place in the same visual tree.

2. Explicitly set the DataContext of the RadPanes to null or non-DependencyObject. This way you will get no errors, but the context will not propagate to the RadPanes. Again, I am not sure if this is desirable in your application, but it work out like this:

<telerikDocking:RadDocking x:Name="docking">     
    <telerikDocking:RadSplitContainer InitialPosition="DockedRight">     
        <telerikDocking:RadPaneGroup >    
            <telerikDocking:RadPane Header="Testing" DataContext="{x:Null}">     
                <TextBlock Text="Text block text..." />    
            </telerikDocking:RadPane>    
        </telerikDocking:RadPaneGroup>    
    </telerikDocking:RadSplitContainer>    
</telerikDocking:RadDocking>   

(Notice the x:Null, which sets the DataContext). This way the application does not throw the error anymore.

3. We change the TabControl so that it will check the type of the DataContext before attempting to set it. This will deal with the error. The only downside is that whenever the DataContext is a DependencyObject, the content of the TabItems/RadPanes will have the same DataContext as the TabConrol/RadPaneGroup. If they are created by an ItemsSource binding, then they will have no way of referencing the correct DataContext object since the bindings in Silverlight 2 do not support collections (e.g. Something[2]). This change may appear in one of the next releases.

Kind regards,
Miroslav
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Docking
Asked by
Julian
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Matthew Cartwright
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or