我有一个文本框
并添加了一个行为:
<TextBox VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Grid.Row="0" Grid.Column="1"
FontSize="22" >
<Binding Path="IpAddr" ValidatesOnNotifyDataErrors="True">
<Binding.ValidationRules>
<local:IpAddressRule />
</Binding.ValidationRules>
</Binding>
<i:Interaction.Behaviors>
<behaviors:TextBoxInputMaskBehavior InputMask="{StaticResource InputMaskIp}" PromptChar="0" />
</i:Interaction.Behaviors>
</TextBox>
现在我已经移动了资源中的 TextBoxInputMaskBehavior
:
<UserControl.Resources>
<system:String x:Key="InputMaskIp">000.000.000.000</system:String>
<behaviors:TextBoxInputMaskBehavior x:Key="mask" InputMask="{StaticResource InputMaskIp}" PromptChar="0" />
</UserControl.Resources>
现在我的问题是,如何将资源绑定(bind)到:
<i:Interaction.Behaviors>
//Will bind resources here.
</i:Interaction.Behaviors>
最佳答案
Interaction.Behaviors
是只读的 BehaviorCollection
继承自 AttachableCollection<Behavior>
& 你不能在其上设置绑定(bind)。
关于c# - 在行为中使用静态资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30391966/