How to specify units in Dialog Units in WPF?

后端 未结 1 1407
一生所求
一生所求 2020-12-21 05:38

i\'m trying to figure out how to layout a simple dialog in WPF using the proper dialog units (DLUs).

i\'ve come up with a simpler example, that cuts strai

1条回答
  •  长情又很酷
    2020-12-21 06:40

    You could try creating a Converter which returns the value multiplied by whatever your DLU is

    For example, I created a MathConverter (code is here) which would let you specify something like

    To make it easier to write and read, you can create a class that inherits from Binding and setup a default binding properties so all you have to do is

    I've never tried overwriting a binding with defaults for Converter and ConverterParameter, but I have overwritten a binding for validation purposes so I believe it's possible.

    The ValidationBinding I created could be used like Text="{local:ValidationBinding MyProperty}" and automatically set ValidatesOnDataError=True, ValidatesOnException=True, UpdateSourceTarget=PropertyChanged in the bindings.

    0 讨论(0)
提交回复
热议问题