我從 ToggleBox 控件向我的組合框添加樣式,一切正常。但是現在我想為何時Validation.HasError為真添加額外的交互。出于某種原因,它告訴我“在‘對象’‘ExtendedComboBoxControl’上找不到‘驗證’屬性”,這是我從 ComboBox 繼承的自定義控件。我嘗試直接在組合框的樣式中使用觸發器,但出于某種原因,我可以從那里更改邊框厚度,但不能更改背景或邊框畫筆。<Style x:Key="ComboBoxToggleButtonStyle" TargetType="{x:Type ToggleButton}"> <Setter Property="OverridesDefaultStyle" Value="true" /> <Setter Property="IsTabStop" Value="false" /> <Setter Property="Focusable" Value="false" /> <Setter Property="ClickMode" Value="Press" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ToggleButton}"> <Border x:Name="templateRoot" Background="{StaticResource ComboBox.Static.Background}" BorderBrush="{StaticResource ComboBox.Static.Border}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true"> <Border x:Name="splitBorder" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Margin="1" Padding="0" HorizontalAlignment="Right" BorderBrush="Transparent" BorderThickness="2,0,0,0" SnapsToDevicePixels="true"> <Path x:Name="arrow" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Data="F1 M 0,0 L 5,5 L 10,0 L 0,0" Fill="{StaticResource Grey500Brush}" /> </Border> </Border>這不是我想要實現的最終交互,但我希望當我將鼠標懸停在組合框背景和邊框刷上時出現驗證錯誤時,這會使組合框背景和邊框刷變為綠色。相反,它告訴我它甚至無法在我的控制下找到該屬性。
1 回答

達令說
TA貢獻1821條經驗 獲得超6個贊
正如 Ed Plunkett 指出的那樣,我需要做的就是改變
<Condition Binding="{Binding Validation.HasError, RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false" />
到
<Condition Binding="{Binding (Validation.HasError), RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}}" Value="false" />
- 1 回答
- 0 關注
- 79 瀏覽
添加回答
舉報
0/150
提交
取消