【发布时间】:2015-09-04 23:09:53
【问题描述】:
我有这个自定义控件,但无法从我的 Main XAML 访问它的成员
<UserControl x:Class="FireflyMmwDiagnostics.Controls.RegisterTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Label Name="LabelRegisterTitle"/>
</Grid>
public partial class RegisterTextBox : UserControl
{
public RegisterTextBox()
{
InitializeComponent();
}
public string RegisterTitle
{
get { return this.LabelRegisterTitle.Content.ToString(); }
set { this.LabelRegisterTitle.Content = value; }
}
这就是我在 Main XAML 中收到的错误消息“无法识别或访问成员 RegisterTitle”:
<Controls:RegisterTextBox RegisterTitle="This Is A Test"/>
我观看了几个 YouTube 视频,他们正是这样做的,并且出于某种原因它对他们有用。 请就这里可能出现的问题提出建议。 谢谢!
【问题讨论】: