Is there a way to mark the entire DataGrid as one-way binding?
+1
A:
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}
Chris Ridenour
2010-03-02 23:14:33
Interesting. It looks like I could do a lot of cool stuff using this.
Jonathan Allen
2010-03-02 23:24:16
I find it a great way to set User and App Settings.One "issue" is XAML editor will complain it cannot find a constructor with one argument. This has been addressed by MS as Will Not Fix. You can "work around" it by moving the class to a separate project in the solution, which for Settings doesn't work but for your case it might. Or if you don't mind the warning (still compiles obviously), ignore it ;)
Chris Ridenour
2010-03-02 23:46:38
That's the kind of patently obvious answer that I could worry over this problem for six months and never find.
Robert Rossney
2010-03-03 00:09:23