Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 439973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:49:35+00:00 2026-05-12T20:49:35+00:00

I am attempting to create an AttachedProperty for a DataGridColumn within Silverlight 3.0 and

  • 0

I am attempting to create an AttachedProperty for a DataGridColumn within Silverlight 3.0 and I am having some issues.

Here is the AttachedProperty:

public class DataGridColumnHelper
{
    public static readonly DependencyProperty HeaderProperty =
        DependencyProperty.RegisterAttached("Header", typeof(string), typeof(DataGridColumnHelper),
                                            new PropertyMetadata(OnHeaderPropertyChanged));

    private static void OnHeaderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        string header = GetHeader(d);

        var dataGridColumn = d as DataGridColumn;

        if (dataGridColumn == null)
        {
            return;
        }

        dataGridColumn.Header = GetHeader(dataGridColumn);
    }

    public static string GetHeader(DependencyObject obj)
    {
        return (string)obj.GetValue(HeaderProperty);
    }

    public static void SetHeader(DependencyObject obj, string value)
    {
        obj.SetValue(HeaderProperty, value);
    }

}

As you can see it is really simple, I am trying to overcome the limitation that the Header Property in the DataGridColumn class cannot be bound.

This XAML works as expected…

<Controls:DataGridTextColumn Binding="{Binding OwnerName}"                                                                         
                         HeaderStyle="{StaticResource DataGridColumnHeaderStyle}"

                         Behaviors:DataGridColumnHelper.Header="User Name"/>

However this XAML throws an error…(Specifically: {System.Windows.Markup.XamlParseException: AG_E_PARSER_PROPERTY_NOT_FOUND [Line: 224 Position: 112]
at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
….})

<Controls:DataGridTextColumn Binding="{Binding OwnerName}"                                                                         
                         HeaderStyle="{StaticResource DataGridColumnHeaderStyle}"

                         Behaviors:DataGridColumnHelper.Header="{Binding Resources.UserNameListViewHeading, Source={StaticResource Labels}}"/>

Just for experimentation I attached this property (with the binding syntax above) to a DataGrid and checked the DataGridColumnHelper.Header property in the OnHeaderPropertyChanged method and the value was correct (and an exception wasn’t thrown)

It is my understanding that the object that the AttachedProperty is attached to must be a DependencyProperty. Looking through Reflector, DataGridColumn (from which DataGridTextColumn derives) derives from DependencyProperty.

Can somebody please shed some light on this? I am trying to Localize our application, and I am having trouble with the DataGrid. I am sure I can do this in code-behind, but I am trying to avoid that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:49:36+00:00Added an answer on May 12, 2026 at 8:49 pm

    Chris, the problem is very simple, this won’t work because the DataGridTextColumn is “detached” from the Visual Tree. Your DataGridTextColumn object is rooted in the Columns collection of the DataGrid – see the indirection. So even attached properties will not work as you expect. Now there is a way to make all this work using something I’m calling Attached Bindings, see:

    http://www.orktane.com/Blog/post/2009/09/29/Introducing-nRouteToolkit-for-Silverlight-(Part-I).aspx

    Just remember to attach the binding properties using something that is in the VisualTree (so the Grid holding the column would do just fine.)

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm attempting to create a generic controller, ie: public class MyController<T> : Controller where
I am attempting to create the following class name signature: public class MyClass<T> where
I am attempting to create a report that contains a list nested within another
I'm attempting to create a simple web application for some personal development, but I've
I'm attempting to create a Product Engine for Apostrophe. I'm having trouble extending the
I'm attempting to create a ListView where I can draw some basic shapes into
I am attempting to create a keyboard hook to use in Java. After some
I'm attempting to create a custom calendar control that inherits from ASP.Net's built in
I'm currently attempting to create a tabbed interface in a web application, and based
I am attempting to create a small application to collect data received from an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.