Jonathan Allen
Jonathan Allen

Reputation: 70307

WPF: One-way binding on entire DataGrid

Is there a way to mark the entire DataGrid as one-way binding?

Upvotes: 2

Views: 1997

Answers (2)

Rachael
Rachael

Reputation: 1993

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

Upvotes: 1

Chris Ridenour
Chris Ridenour

Reputation: 594

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}

Upvotes: 1

Related Questions