【发布时间】:2017-12-01 14:41:18
【问题描述】:
我在后面的代码中创建了以下自定义Dependency Property。
这个 infragistics XamDataGrid 类型的依赖属性等等的所有者。
我正在尝试通过此属性获取网格的引用。
以下代码编译时没有错误或警告。但是,Dependency Property 不会显示在 XAML intelliSense 中。
我也尝试过输入全名。它不承认这个DP。 我已经清理了项目并重建了它。 我什至关闭了 Visual Studio 并重新打开它。
using System.Windows;
using Infragistics.Windows.DataPresenter;
namespace Demo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
public static readonly DependencyProperty DPRProperty =
DependencyProperty.Register(
"DPR",
typeof(XamDataGrid),
typeof(MainWindow),
new FrameworkPropertyMetadata(null));
public XamDataGrid DPR
{
get { return (XamDataGrid)GetValue(DPRProperty); }
set { SetValue(DPRProperty, value); }
}
}
}
【问题讨论】:
-
你试过了吗:清洁解决方案 + 重建
-
@jHilscher 是的。我在问题中指定了这一点。
-
您的意思是当您在
<Window ...>标记内输入XAML 编辑器时? -
@Clemens 在 Window 标签中是。
-
嗯,那里是
Window,而不是MainWindow。但无论如何,这一切似乎都没有意义。您将如何分配 XamDataGrid?您可能想要做的就是在 MainWindow 的 XAML 中的某处添加一个 XamDataGrid,并分配x:Name属性,这将为您生成一个访问该元素的成员变量。
标签: c# wpf xaml dependency-properties infragistics