我有一個看起來像這樣的文本框:-
<TextBox Text="{Binding Scale, NotifyOnValidationError=True,
UpdateSourceTrigger=LostFocus, NotifyOnSourceUpdated=True, StringFormat={}{0:g5}}" />
我想對 Text 屬性使用多值轉換器,因為我想StringFormat在 xaml 中系結而不是對其進行硬編碼(類似于this)。我是否正確地說使用這樣的轉換器讓我無法指定進一步的系結運算式“引數”,例如NotifyOn...和UpdateSourceTrigger在我的示例中看到的?(我意識到 UpdateSourceTrigger 默認是LostFocus,但有時我可能想使用 PropertyChanged,例如)。
uj5u.com熱心網友回復:
我是否說使用這樣的轉換器讓我無法指定進一步的系結運算式“引數”......?
不,MultiBinding 也具有所有這些屬性,您可以像這樣指定它們:
<TextBox>
<TextBox.Text>
<MultiBinding Converter="{StaticResource YourConverter}"
NotifyOnValidationError="True"
NotifyOnSourceUpdated="True"
UpdateSourceTrigger="LostFocus">
<Binding Path="Scale"/>
<Binding Path="YourStringFormat"/>
</MultiBinding>
</TextBox.Text>
</TextBox>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/313994.html
