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

GridViewDataColumn.Header Binding cause Unhandled Error

11 Answers 285 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Wirat Chinnan
Top achievements
Rank 1
Wirat Chinnan asked on 24 Aug 2009, 07:22 AM
When I try to binding to GridViewDataColumn.Header as shown below

...
<telerik:GridViewDataColumn
         Header="{Binding Path=DataContext.OwnerForm.Lang,ElementName=FormRoot,Mode=OneWay,Converter={StaticResource langconv},ConverterParameter='Name'}"
          DataMemberPath="name"
/>
...

Unhandled Error is throw.

How can I solve this problem?

Thank you in advance.

FYI
1. I think the Binding Expression should work because it can be used another place both wpf and silverlight.
2. The Converter langConv return Thai Caption of Word "Name" as String.
3. Sorry for my poor english.

11 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 25 Aug 2009, 01:57 PM

Hello Wirat Chinnan,

I am trying to reproduce the problem here , but with no success so far. Can you please give me more details on the error e.g. what exactly is the exception. Any Call stack info should be very helpfull also .

Any other info that you think my help me to reproduce the error will be appreciated .

Greetings,

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
Wirat Chinnan
Top achievements
Rank 1
answered on 25 Aug 2009, 04:00 PM
Hello Pavel Pavlov

I try to make more simple example that can reproduce the error as shown below

<UserControl x:Class="HeaderBindingTest.MainPage"
    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="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:tkgrid="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
    xmlns:tki="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"    
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
        <StackPanel>
            <TextBox x:Name="TextBox1" Text="Test" />
            <TextBlock Text="{Binding Path=Text,ElementName=TextBox1}" />
            <telerik:RadGridView Name="RadGridView1" ColumnsWidthMode="Auto" AutoGenerateColumns="False"
                                                          ActionOnLostFocus="CommitEdit"
                                                          UseAlternateRowStyle="True" >
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="{Binding Path=Text,ElementName=TextBox1}">
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
        </StackPanel>
    </Grid>      
</UserControl>

when Binding in TextBlock.Text is work but in GridViewDataColumn.Header is not work

and Exception is

Error: Unhandled Error in Silverlight Application AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 17 Position: 52]   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at HeaderBindingTest.MainPage.InitializeComponent()
   at HeaderBindingTest.MainPage..ctor()
   at HeaderBindingTest.App.Application_Startup(Object o, StartupEventArgs 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)
Source File: http://localhost:1097/HeaderBindingTestTestPage.aspx
Line: 0

Thank you in advance

Wirat Chinnan

FYI
  - This project use Telerik version 2009.2.812.1030
 
0
Accepted
Pavel Pavlov
Telerik team
answered on 28 Aug 2009, 11:58 AM
Hello Wirat Chinnan,

Instead of setting binding directly to the header property , please try using the following XAML.
I believe this will do the trick :

<telerik:GridViewDataColumn  ...> 
                    <telerik:GridViewDataColumn.Header> 
                        <TextBlock Text="{Binding Path=Text,ElementName=TextBox1}" /> 
                    </telerik:GridViewDataColumn.Header> 
                </telerik:GridViewDataColumn> 


Sincerely yours,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Wirat Chinnan
Top achievements
Rank 1
answered on 28 Aug 2009, 02:44 PM
Hello Pavel Pavlov

It work.

Thank you very much

Wirat Chinnan
0
Joy George
Top achievements
Rank 1
answered on 09 Oct 2009, 05:16 PM
Is it possible to databind IsVisible property of GridViewDataColumn in this way?
If so please give me the code snippet.

 

0
Vlad
Telerik team
answered on 12 Oct 2009, 05:50 AM
Hi Joy,

Binding can work only on controls and since grid columns are not you cannot bind column properties.

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Joy George
Top achievements
Rank 1
answered on 12 Oct 2009, 06:44 AM
Hi Vlad,
Thanks for the reply.

We are using MVVM in our application and we would like to set header values through binding.

Do you have any workarounds to achieve the same or any time frame for your next release which contains the fix for this?

Thanks
Joy
0
Vlad
Telerik team
answered on 12 Oct 2009, 07:02 AM
Hello Joy,

This is limitation of Silverlight in general however MS guys promised fix for Silverlight 4. Unfortunately I'm not aware of any workaround using MVVM.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saket S
Top achievements
Rank 1
answered on 26 Nov 2009, 07:52 AM
Hi Pavel,

i used below code to bind the header text by propertyName. There is no error, but header will not display the text.
can you please help.....
<telerik:GridViewDataColumn  ...> 
                    <telerik:GridViewDataColumn.Header> 
                        <TextBlock Text="{Binding PropertyName}" /> 
                    </telerik:GridViewDataColumn.Header> 
                </telerik:GridViewDataColumn> 

Regards,
S.s
0
Vlad
Telerik team
answered on 26 Nov 2009, 07:58 AM
Hi,

Since there is no DataContext for column headers you need to point to specific context using ElementName for example.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
meena
Top achievements
Rank 1
answered on 05 Aug 2011, 11:23 AM
Hi,

It still is not getting the value in the DataColumn Header.

for the Code below:
Is anything missing.

 

 

 

<TextBlock x:Name="testOIL" Text="{Binding OilHeader}" Grid.Row="0"/>

 

 

 

 

<telerikGrid:RadGridView x:Name="DataLog" RowStyle="{StaticResource GridViewStyle}" IsReadOnly="True" AutoGenerateColumns="False" Grid.Row="1" CanUserFreezeColumns="False"

 

 

 

VerticalAlignment="Top" ItemsSource="{Binding Logs, Mode=TwoWay}" SelectedItem="{Binding LogEntry}" IsSynchronizedWithCurrentItem="true">

 

 

 

 

<telerikGrid:RadGridView.Columns>

 

 

 

 

<telerikGrid:GridViewDataColumn Width="Auto" IsReadOnly="True" DataMemberBinding="{Binding OilPressure}" DataFormatString="{}{0:F2}">

 

 

 

 

 

 

 

 

<telerikGrid:GridViewDataColumn.Header>

 

 

 

 

 

 

 

 

<TextBlock Text="{Binding Path=Text, ElementName=testOIL}" />

 

 

 

 

 

 

 

 

</telerikGrid:GridViewDataColumn.Header>

 

 

 

 

 

 

 

 

</telerikGrid:GridViewDataColumn>

 

 

 

</telerikGrid:RadGridView.Columns>

 

 

 

 

</telerikGrid:RadGridView>

 

Tags
GridView
Asked by
Wirat Chinnan
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Wirat Chinnan
Top achievements
Rank 1
Joy George
Top achievements
Rank 1
Vlad
Telerik team
Saket S
Top achievements
Rank 1
meena
Top achievements
Rank 1
Share this question
or