相关疑难解决方法(0)

PathGeneratedInternal标志在WPF绑定中做了什么?

我刚刚在这里回答了一个问题,我说在两者之间没有功能差异

 {Binding TargetProperty}
Run Code Online (Sandbox Code Playgroud)

 {Binding Path=TargetProperty}
Run Code Online (Sandbox Code Playgroud)

而且,据我所知,我所写的内容基本上是正确的.然而,一个人将使用构造函数和另一个设置属性的想法让我觉得可能存在差异,所以我鞭打开放反射器并看了一眼.

构造函数中包含以下代码:

public Binding(string path)
{
    this._source = UnsetSource;
    if (path != null)
    {
        if (Dispatcher.CurrentDispatcher == null)
        {
            throw new InvalidOperationException();
        }
        this._ppath = new PropertyPath(path, new object[0]);
        this._attachedPropertiesInPath = -1;
    }
}
Run Code Online (Sandbox Code Playgroud)

path属性是这样的:

public PropertyPath Path
{
    get
    {
        return this._ppath;
    }
    set
    {
        base.CheckSealed();
        this._ppath = value;
        this._attachedPropertiesInPath = -1;
        base.ClearFlag(BindingBase.BindingFlags.PathGeneratedInternally);
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,当您通过属性设置路径时,将清除PathGeneratedInternally标志.现在,这个标志没有公开直接暴露在任何地方,但似乎确实在几个地方使用:

internal void UsePath(PropertyPath path)
{
    this._ppath = path;
    base.SetFlag(BindingBase.BindingFlags.PathGeneratedInternally);
}

[EditorBrowsable(EditorBrowsableState.Never)]
public bool …
Run Code Online (Sandbox Code Playgroud)

wpf binding

5
推荐指数
1
解决办法
861
查看次数

DataGrid如何绑定到任何集合的属性?

我正在制作一个WPF用户控件,我希望在绑定意义上与DataGrid控件类似.我的问题是:DataGrid如何知道如何绑定到IEnumerable类型的任何集合?例如:您可以将DataView作为ItemsSource传递,也可以传递任何对象集合.DataGrid如何通过查看以下内容来决定是绑定到DataView列还是绑定到对象的属性:

<DataGridTextColumn Binding="{Binding **Path=SomePropertyOrColumn**}"/>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

c# wpf binding datagrid

5
推荐指数
1
解决办法
519
查看次数

标签 统计

binding ×2

wpf ×2

c# ×1

datagrid ×1