locked
Visual Studio 2013 Custom XAML property not working

    Question

  • Hi there,

    I have a XAML control with a public string property, but no matter what I do I can't access it withing XAML.  It tells me the property is not recognised or accessible, but it works perfectly in code.

        public sealed partial class SectionHeader : UserControl
        {
    
            public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title",
                typeof(String),
                typeof(SectionHeader),
                new PropertyMetadata("Title", TitleChangedCallback));
    
    
            public String Title
            {
                get { return (GetValue(TitleProperty) as String); }
                set
                {
                    SetValue(TitleProperty, value);
                }
            }
    
            public SectionHeader()
            {
                this.InitializeComponent();
            }
    
    
            private static void TitleChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
            {
                //apply to xaml control
            }
    
        }

    I've tried both as a dependency property and also just a public property but the following just will not work,

    <local:SectionHeader x:Name="fuck" Title="jnk" Width="256" />

    Plus there are loads of XAML related bugs in VS 2013 that i've noticed like it telling me a control doesn't exist in the code behind, yet compiles and runs perfectly.

    How can I work around this?


    Somewhere out there...

    Friday, March 28, 2014 4:17 PM

Answers

  • Hi,

    I test your project. Your codes are all correct and that's problem is a known issue in VS2013. If you run the app and return to the xaml again you will find the error disappeared. You can go to connect to post your issue as VS bug:

    http://connect.microsoft.com/

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, March 31, 2014 4:11 AM

All replies

  • Hi,

    I test your project. Your codes are all correct and that's problem is a known issue in VS2013. If you run the app and return to the xaml again you will find the error disappeared. You can go to connect to post your issue as VS bug:

    http://connect.microsoft.com/

    Best Wishes!


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey. Thanks<br/> MSDN Community Support<br/> <br/> Please remember to &quot;Mark as Answer&quot; the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, March 31, 2014 4:11 AM
  • Hi there,  thanks you're right, it works even with the compiler error!

    thanks.


    Somewhere out there...

    Monday, March 31, 2014 8:32 AM