views:

38

answers:

1

I'm almost sure the answer is simply no, you can't do that.

So I'm working on options for my app. I've got a decent setup so I have the global options and the local options since you can have different options selected on different tabs.

For the global options I want to represent when an option isn't consistent across all the tabs by returning null.

I want to reuse the UI binding to the object so I was thinking I could have the a version of the Options object that is derived and overides most of it's property accessors, but for options that normally support bool, I'd need to be able to return nullable to show inconsistency.

But I don't want to change the Options interface to use nullable types, but I want to reuse bindings. But I think I have to pick one.

A: 

I'm not sure what you're using to create the UI but there is plenty of information about the MVVM pattern for WPF which is perfect for this kind of thing. The idea is that you would create an abstraction of the underlying object (the "model", which has the non-nullable boolean properties) and wrap them such that they get/set nullable booleans instead. This abstraction is called the "viewmodel" and your view binds to it instead of directly to the model. You also can implement property change notification and other features to make databinding easier in the viewmodel.

MVVM tag on StackOverflow for more info.

Josh Einstein
Yeah I think this is the answer. I failed to mention that the portion of the app I'm working on is the model, which in most cases doesn't really need much transformation, in this instance deffinetly could use this pattern. SO I need an interfaceViewModel class, then two ViewModel version to represent the two different Options, 1 for the regular options and 1 for the global version of options.
Joel Barsotti