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 ISDescriptionEnabledProper ty = DependencyProperty.Registe r("ISDescr iptionEnab led", typeof(bool), typeof(UCComboTextbox), new PropertyMetadata(false));
public static readonly DependencyProperty DescriptionVisibilityPrope rty = DependencyProperty.Registe r("Descrip tionVisibi lity", typeof(Visibility), typeof(UCComboTextbox), new PropertyMetadata(false));
public static DependencyProperty TitleProperty = DependencyProperty.Registe r("Title", typeof(string), typeof(UCComboTextbox), new PropertyMetadata(false));
public static DependencyProperty DescProperty = DependencyProperty.Registe r("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.S erverNickN ame}"
Desc="{x:Static resx:AddUpdateServerView.S erverNickN ameDesc}" />
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 ISDescriptionEnabledProper
public static readonly DependencyProperty DescriptionVisibilityPrope
public static DependencyProperty TitleProperty = DependencyProperty.Registe
public static DependencyProperty DescProperty = DependencyProperty.Registe
public bool ISDescriptionEnabled {get;set;}
public Visibility DescriptionVisibility
{
get
{
if (ISDescriptionEnabled)
return System.Windows.Visibility.
else
return System.Windows.Visibility.
}
}
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"
Title="{x:Static resx.AddUpdateServerView.S
Desc="{x:Static resx:AddUpdateServerView.S
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
looks like you didnt refference the dll :/
ASKER
The bug is in the DepedencyProperty.
(1) It needs both get and set
(2) It needs Default value set.
(1) It needs both get and set
(2) It needs Default value set.