我有一个DependencyObject(即Interactivity行为),我想从代码中获取它的x:Name(只是获取,不是设置)。这个可能吗?
编辑:根据AnthonyWJones的答案:
我已经将以下代码插入到我的基本行为中:
[EditorBrowsable(EditorBrowsableState.Never)]
public string Name
{
get { return (string)GetValue(NameProperty); }
set { SetValue(NameProperty, value); }
}
public static readonly DependencyProperty NameProperty =
DependencyProperty.Register("Name", typeof(string), typeof(BaseBehavior<T>), new PropertyMetadata(null));
我已经给我的行为设置了x:Name,但是Name属性没有被填充。