【发布时间】:2018-07-31 18:49:51
【问题描述】:
我创建了一个小型 WPF 应用程序,并且页面上有许多文本框。所有这些文本框都有圆角。
我使用了 MVVM 模式并实现了 IDataErrorInfo 接口来向用户显示错误。当其中一个文本框的边缘为空时,工具提示应显示为红色,我已成功完成。
我现在希望红色边缘也像文本框一样具有圆角。如图所示,红色边框显示为TextBox为空,红色边框需要有圆角半径。
<!-- Text box xaml code that is used to display the error and binding -->
<TextBox Style="{StaticResource TextBoxBase}"
Name="FirstName"
Text="{Binding FirstName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Source={StaticResource CustomerObject}, ValidatesOnDataErrors=True}"/>
<!-- Code that changes the tool tip if it's null -->
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors).CurrentItem.ErrorContent}" />
</Trigger>
</Style.Triggers>
【问题讨论】:
-
我对 XAML 和 WPF 比较陌生,并且不确定如何具体做到这一点