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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:46:13+00:00 2026-06-14T15:46:13+00:00

I’d like to create an attached property in my C++/Cx WinRT project. When I

  • 0

I’d like to create an attached property in my C++/Cx WinRT project. When I do so, the XAML compiler complains that I’m using an unknown property.

I’m declaring my attached property in a cpp file as such:

/*--------------------------------------------------------------------
    Forward Declarations
--------------------------------------------------------------------*/
namespace
{
    void
    StateChanged(
        DependencyObject^ target,
        DependencyPropertyChangedEventArgs^ args);
}

/*--------------------------------------------------------------------
    DependancyProperty setup for the view model
--------------------------------------------------------------------*/
namespace
{
DependencyProperty^ _stateProperty =
    DependencyProperty::RegisterAttached(
        "State",
        TypeName(Platform::String::typeid),
        TypeName(VisualStateManagerBindingHelper::typeid),
        ref new PropertyMetadata(nullptr, ref new PropertyChangedCallback(&StateChanged)));
}

namespace
{
    void
    StateChanged(
        DependencyObject^ target,
        DependencyPropertyChangedEventArgs^ args)
    {
        if (args->NewValue != nullptr)
        {
            VisualStateManager::GoToState(safe_cast<Control^>(target), safe_cast<String^>(args->NewValue), true);
        }
    }
}

In my XAML file, I’m attempting to use the attached property as such:

<UserControl
    xmlns:local="using:MyCustomNamespace"
    ...

    <Grid Grid.Column="1" local:VisualStateManagerBindingHelper.State="{Binding Path=SomeViewModelProperty, Mode=TwoWay}">
        ...

When I compile, I’m faced with this error:

XamlCompiler error WMC0010: Unknown attachable member ‘VisualStateManagerBindingHelper.State’ on element ‘Grid’

It appears to me as if the XAML compiler is supposed to get a hint somewhere that this attached property is allowed, but I don’t know how to give it that hint. This article on the same subject suggests that the DependancyProperty should be public. I’m not entirely sure how to do that in C++.

My ultimate goal is to bind a visual state group’s state to some view model property. The method to do this is outlined in the accepted answer in this question. Unfortunately, the code provided there is C# and I can’t seem to translate it over to C++ properly.

Finally, I noticed the SuspensionManager that comes with Visual Studio’s new project templates defines an attached property almost exactly like I do, but they don’t show any examples of it in use. This makes me feel like I’m on track, but missing some small piece of the puzzle.

  • 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-06-14T15:46:14+00:00Added an answer on June 14, 2026 at 3:46 pm

    I found a site that answered my question! As I suspected, you need to have your class defined in a very specific way for the XAML preprocessor to know about your attached property. All of the requirements along with a code sample are available here.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.