开发者

WPF: One-way binding on entire DataGrid

开发者 https://www.devze.com 2022-12-22 03:51 出处:网络
Is there a way to mark the e开发者_如何学Gontire DataGrid as one-way binding?You can create a new class such as OneWayExtension that inherits binding.

Is there a way to mark the e开发者_如何学Gontire DataGrid as one-way binding?


You can create a new class such as OneWayExtension that inherits binding.

 public class OneWayExtension : Binding
{
    public OneWayExtension()
        : base()
    {
        Initialize();
    }

    public OneWayExtension(string path)
        : base(path)
    {
        Initialize();
    }

    private void Initialize()
    {
        this.Source = YourSourceOrMakeThisAParameter;
        this.Mode = BindingMode.OneWay;
    }
}

You can then call this by

{local:OneWay PathOfData}


I know this is already answered, but can't you just set the binding Mode on the DataGrid's ItemsSource property to OneWay?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号