GridViewDataColumn.Header Binding cause Unhandled Error

12 posts, 1 answers
  1. Wirat Chinnan
    Wirat Chinnan avatar
    13 posts
    Member since:
    Aug 2009

    Posted 24 Aug 2009 Link to this post

    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.
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 25 Aug 2009 Link to this post

    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.
  3. Wirat Chinnan
    Wirat Chinnan avatar
    13 posts
    Member since:
    Aug 2009

    Posted 25 Aug 2009 Link to this post

    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
     
  4. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 28 Aug 2009 Link to this post

    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.
  5. Wirat Chinnan
    Wirat Chinnan avatar
    13 posts
    Member since:
    Aug 2009

    Posted 28 Aug 2009 Link to this post

    Hello Pavel Pavlov

    It work.

    Thank you very much

    Wirat Chinnan
  6. Joy George
    Joy George avatar
    2 posts
    Member since:
    Oct 2009

    Posted 09 Oct 2009 Link to this post

    Is it possible to databind IsVisible property of GridViewDataColumn in this way?
    If so please give me the code snippet.

     

  7. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Oct 2009 Link to this post

    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.
  8. Joy George
    Joy George avatar
    2 posts
    Member since:
    Oct 2009

    Posted 12 Oct 2009 Link to this post

    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
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 12 Oct 2009 Link to this post

    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.
  10. Saket S
    Saket S avatar
    22 posts
    Member since:
    Nov 2009

    Posted 26 Nov 2009 Link to this post

    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
  11. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Nov 2009 Link to this post

    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.
  12. meena
    meena avatar
    6 posts
    Member since:
    Sep 2010

    Posted 05 Aug 2011 Link to this post

    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>

     

Back to Top