As this solution is fairly simple, I've chose not to make it more complex than it should. That is why, for example, I chose to use a pre-defined set of bindings in the Multi-Binding solution rather than add an elaborated mechanism that will obscure the main ideas I'm hoping to convey.
This solution is a variant of a technique I've already shown in my article ' Silverlight Multi-Binding ' with some WPF and context specific modifications and tweaks. Bindings and property are set to the element's matching attached properties, and the return value is set to a new Binding's referencing the element's CustomBindingUtil. In your particular case, all you need to do is format a converted value to a string.
StringFormat property on a Binding is your friend here. Here is a small extension of Town's answer to support multi-binding:. HOW TO? Thanks, Josh. Joey Joey k 80 80 gold badges silver badges bronze badges. You may not even need a Binding Converter at all. Clemens Clemens k 10 10 gold badges silver badges bronze badges. Generally a DataTrigger should be a bit lighter than a Converter, right? It's clearer to see how it behaves.
Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. You can further simplify the accepted answer.
Instead of typing out the enums as strings in xaml and doing more work in your converter than needed, you can explicitly pass in the enum value instead of a string representation, and as CrimsonX commented, errors get thrown at compile time rather than runtime:.
Thanks to anon for suggesting returning Binding. DoNothing rather than DependencyProperty. In cases where your related RadioButtons cannot share a single parent container, then set the GroupName property of each RadioButton to a common value to logically group them. Of course, you can avoid this issue if you are able to move your enum type to the namespace directly.
0コメント