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 872877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:51:00+00:00 2026-05-15T10:51:00+00:00

In Xaml I can set a custom attached property using local:TestClass.TestProperty=1 An I can

  • 0

In Xaml I can set a custom attached property using
local:TestClass.TestProperty=”1″

An I can bind to a custom attached property using
{Binding Path=(Namespace:[OwnerType].[PropertyName])}
{Binding Path=(local:TestClass.TestProperty)}

But how do I specify the namespace when I need to use a custom attached property in a SortDescription?
I can bind to an attached property using
new SortDescription(“(Grid.Row)”, ListSortDirection.Descending)
but here I can’t set a namespace anywhere…

Best Regards,
Jesper

  • 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-15T10:51:01+00:00Added an answer on May 15, 2026 at 10:51 am

    You can’t, for the same reason that {Binding Path=a:b.c} works but {Binding a:b.c} doesn’t: The PropertyPath constructor has no namespace context.

    Unfortunately in the case of SortDescription there isn’t much you can do about it. You have to find a way to sort without using attached properties.

    Normally I tell people that use of Tag is an indicator of bad coding, but in this case Tag may be your best option: You can create an object within Tag that has properties that return the actual attached properties you want.

    In your PropertyChangedCallback, instantiate Tag to an instance of an inner class:

    public class TestClass : DependencyObject
    {
      ... TestProperty declaration ...
      PropertyChangedCallback = (obj, e) =>
      {
        ...
        if(obj.Tag==null) obj.Tag = new PropertyProxy { Container = obj };
      });
    
      public class PropertyProxy
      {
        DependencyObject Container;
        public SomeType TestProperty { get { return GetTestProperty(Container); } }
      }
    }
    

    Now you can use the sub-property of Tag in your SortDescription:

    <SortDescription PropertyName="Tag.TestProperty" />
    

    If there is only a single property to be sorted, you can simply use the Tag for it.

    The main problem with this is that using the Tag property will conflict with any other code that also tries to use the Tag. So you may want to look for some obscure DependencyProperty in the standard libraries that doesn’t even apply to the objects in question and use that instead of Tag.

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

Sidebar

Related Questions

To bind to the current DataContext in XAML you can use: <TextBlock Text={Binding} />
I'm using XAML data binding for a ListBox whose ItemSource is set to a
I want to set up data binding using a custom component. Basically, I'd like
I am trying to bind a dependency property via XAML to my custom WPF
In XAML you can do <TabItem Selector.Selected=myEvenHandler></TabItem> to set the event handler for when
13 minutes ago | LINK In xaml, a hyperlink can be set as <HyperlinkButton
How can I change a XAML code (which represent a set of shapes) to
In XAML we can put one long string in the positions property, How do
I'm trying to create a custom set of classes that can be added to
How do you set a custom MarkupExtension from code? You can easily set if

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.