WPF Usercontrol property inaccessible

chuang4630
chuang4630 used Ask the Experts™
on
I have created a simple UC control, which combines two TextBlock and one Textbox.
But when I use this UC,it compains of"not recognized or is not accessible.

Error:
The member "Title" is not recognized or is not accessible.

I use .NET 4.5, VS2012.

Anyone can help? THANKS a LOT!

    public partial class UCComboTextbox : UserControl
    {
        public static DependencyProperty ISDescriptionEnabledProperty = DependencyProperty.Register("ISDescriptionEnabled", typeof(bool), typeof(UCComboTextbox), new PropertyMetadata(false));
        public static readonly DependencyProperty DescriptionVisibilityProperty = DependencyProperty.Register("DescriptionVisibility", typeof(Visibility), typeof(UCComboTextbox), new PropertyMetadata(false));
        public static DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(UCComboTextbox), new PropertyMetadata(false));
        public static DependencyProperty DescProperty = DependencyProperty.Register("Desc", typeof(string), typeof(UCComboTextbox), new PropertyMetadata(false));

        public bool ISDescriptionEnabled {get;set;}
        public Visibility DescriptionVisibility
        {
            get
            {
                if (ISDescriptionEnabled)
                    return System.Windows.Visibility.Visible;
                else
                    return System.Windows.Visibility.Collapsed;
            }
        }

        public string Title { get; set; }
        public string Desc { get; set; }

        public UCComboTextbox()
        {
            InitializeComponent();
            DataContext = this;            
        }
    }
}


The xaml that uses this UC:

        <local:UCComboTextbox x:Uid="ServerName" x:Name="ServerName" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,30,0,0"
                              Title="{x:Static resx.AddUpdateServerView.ServerNickName}"
                              Desc="{x:Static resx:AddUpdateServerView.ServerNickNameDesc}" />
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:

Commented:
looks like you didnt refference the dll :/

Author

Commented:
The bug is in the DepedencyProperty.

(1) It needs both get and set
(2) It needs Default value set.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial