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

[Solved] Error thrown setting ItemSource when AlignmentContentPresenter used

4 Answers 135 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tom
Top achievements
Rank 1
Tom asked on 19 Aug 2009, 08:22 AM
I'm trying to use an AlignmentContentPresenter to wrap the header text on a GridView. Works fine until I try and reset the ItemSource for the grid, at which point the app throws a xaml error at line 0 position 0.

Got a very small app to demonstrate. Hopefully something I'm just not doing right in the XAML, but looks like a bug to me.

Thanks
Tom

XAML:
<UserControl xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"   
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"   
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"   
    xmlns:Telerik_Windows_Controls_GridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView" 
             mc:Ignorable="d"  x:Class="SilverlightApplication1.MainPage" 
    d:DesignWidth="640" d:DesignHeight="480">  
  <Grid x:Name="LayoutRoot">  
<telerikGridView:RadGridView Name="dg1" Height="110" VerticalAlignment="Top" AutoGenerateColumns="False">  
            <telerikGridView:RadGridView.Columns> 
                <telerikGridView:GridViewDataColumn UniqueName="val" > 
                    <telerikGridView:GridViewDataColumn.Header > 
                        <Telerik_Windows_Controls_GridView:AlignmentContentPresenter TextWrapping="Wrap" Content="Jan 4/4/4" /> 
                    </telerikGridView:GridViewDataColumn.Header> 
                </telerikGridView:GridViewDataColumn> 
            </telerikGridView:RadGridView.Columns> 
        </telerikGridView:RadGridView> 
    <Button Name="Button1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="85" Content="Reset Source" Margin="0,120,0,0"/>  
    </Grid> 
</UserControl> 
C#:
using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Net;  
using System.Windows;  
using System.Windows.Controls;  
using System.Windows.Documents;  
using System.Windows.Input;  
using System.Windows.Media;  
using System.Windows.Media.Animation;  
using System.Windows.Shapes;  
using System.Collections.ObjectModel;  
 
namespace SilverlightApplication1  
{  
    public partial class MainPage : UserControl  
    {  
        public ObservableCollection<DataRow> myData;  
 
        public MainPage()  
        {  
            InitializeComponent();  
 
            myData = new ObservableCollection<DataRow>();  
            myData.Add(new DataRow(1));  
            myData.Add(new DataRow(2));  
 
            dg1.ItemsSource = myData;  
 
            this.Button1.Click += new RoutedEventHandler(Button1_Click);  
 
        }  
 
        void Button1_Click(object sender, RoutedEventArgs e)  
        {  
            myData = new ObservableCollection<DataRow>();  
            myData.Add(new DataRow(1));  
            myData.Add(new DataRow(2));  
 
            dg1.ItemsSource = myData;  
 
        }  
    }  
 
    public class DataRow  
    {  
        public DataRow(int newVal)  
        {  
            val = newVal;  
        }  
        public int val  
        {  
            set;  
            get;  
        }  
    }  
}  
 

4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Aug 2009, 12:43 PM
Hi Tom,

Can you please specify which version of the dlls do you use  ?

All the best,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tom
Top achievements
Rank 1
answered on 20 Aug 2009, 11:08 PM
Hi Pavel,

This is all with the latest build. This is a snippet from the project file:

<ItemGroup> 
    <Reference Include="System.Windows" /> 
    <Reference Include="mscorlib" /> 
    <Reference Include="system" /> 
    <Reference Include="System.Core" /> 
    <Reference Include="System.Net" /> 
    <Reference Include="System.Windows.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    <Reference Include="System.Xml" /> 
    <Reference Include="System.Windows.Browser" /> 
    <Reference Include="System.Xml.Linq, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /> 
    <Reference Include="Telerik.Windows.Controls, Version=2009.2.812.1030, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">  
      <SpecificVersion>False</SpecificVersion> 
      <HintPath>..\..\..\..\Program Files\Telerik\RadControls for Silverlight Q2 2009\Binaries\Silverlight\Telerik.Windows.Controls.dll</HintPath> 
    </Reference> 
    <Reference Include="Telerik.Windows.Controls.GridView, Version=2009.2.812.1030, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">  
      <SpecificVersion>False</SpecificVersion> 
      <HintPath>..\..\..\..\Program Files\Telerik\RadControls for Silverlight Q2 2009\Binaries\Silverlight\Telerik.Windows.Controls.GridView.dll</HintPath> 
    </Reference> 
    <Reference Include="Telerik.Windows.Controls.Input, Version=2009.2.812.1030, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">  
      <SpecificVersion>False</SpecificVersion> 
      <HintPath>..\..\..\..\Program Files\Telerik\RadControls for Silverlight Q2 2009\Binaries\Silverlight\Telerik.Windows.Controls.Input.dll</HintPath> 
    </Reference> 
    <Reference Include="Telerik.Windows.Data, Version=2009.2.812.1030, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">  
      <SpecificVersion>False</SpecificVersion> 
      <HintPath>..\..\..\..\Program Files\Telerik\RadControls for Silverlight Q2 2009\Binaries\Silverlight\Telerik.Windows.Data.dll</HintPath> 
    </Reference> 
  </ItemGroup> 
0
Accepted
Pavel Pavlov
Telerik team
answered on 24 Aug 2009, 03:15 PM
Hello Tom,
It appears you have hit a bug . It seems that setting the Header property to any UIElement will generate an exception when trying to change the ItemsSource.
Thank you for reporting this one ! I have updated your Telerik points.
Meanwhile we have fixed the bug . It will be included in our very next internal build and will be available for download in your client.net account.
Please excuse us for the inconvenience caused.

Sincerely yours,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tom
Top achievements
Rank 1
answered on 24 Aug 2009, 11:47 PM
Thanks Pavel.

Your wording of "when trying to change the ItemsSource" led me to my workaround.

As long as I only set the ItemSource once, then instead of resetting the itemsource I clear and reset the contents of the underlying collection, I can get it to work.

Thankyou for your help.

Regards,
Tom
Tags
GridView
Asked by
Tom
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Tom
Top achievements
Rank 1
Share this question
or