Link to home
Start Free TrialLog in
Avatar of chuang4630
chuang4630

asked on

WPF Usercontrol property inaccessible

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}" />
ASKER CERTIFIED SOLUTION
Avatar of Ess Kay
Ess Kay
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks like you didnt refference the dll :/
Avatar of chuang4630
chuang4630

ASKER

The bug is in the DepedencyProperty.

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