DataGrid ComboBox: keyboard-focused item uses an undefined brush key (MaterialDesign.Brush.TextBox.ComboBoxHover)

Đang mở Phù hợp với người mới
#4,124 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
88/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
desktop-dev

Hướng nghiên cứu

Vấn đề nằm trong src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml quanh dòng 60, trong MultiTrigger của trạng thái focus bằng bàn phím thuộc item container template. So sánh khóa ở đó với khóa được dùng bởi mouse-over trigger ở dòng 53 và kiểm tra xem nó có được định nghĩa trong MaterialDesignTheme.Light.xaml và Dark.xaml hay không. Hoàn thành khi mục đang focus được làm nổi bật khi điều hướng bằng phím mũi tên, bạn có thể xác nhận bằng cách chạy ví dụ DataGrid ComboBox của ứng dụng mẫu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug explanation

src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DataGrid.ComboBox.xaml, line 60, in the item container template of the DataGrid ComboBox:

<MultiTrigger>
  <MultiTrigger.Conditions>
    <Condition Property="IsSelected" Value="False" />
    <Condition Property="IsKeyboardFocused" Value="True" />
  </MultiTrigger.Conditions>
  <Setter TargetName="Bd" Property="Background" Value="{DynamicResource MaterialDesign.Brush.TextBox.ComboBoxHover}" />
</MultiTrigger>

No resource with the key MaterialDesign.Brush.TextBox.ComboBoxHover is defined anywhere in the repository (GitHub code search finds only this line). The trigger right above it — the mouse-over case, line 53 — uses MaterialDesign.Brush.DataGrid.ComboBoxHover, which is defined in both MaterialDesignTheme.Light.xaml and MaterialDesignTheme.Dark.xaml (line 39), and lines 171 and 297 use the same key. So this looks like the keyboard-focus trigger was meant to use it too.

Since it is a DynamicResource, nothing throws: the background just doesn't change when an item gets keyboard focus, so someone moving through the dropdown with the arrow keys gets no highlight on the focused item. I found this by reading the source and haven't run it, so apologies if I'm missing something.

Suggested change (line 60):

<Setter TargetName="Bd" Property="Background" Value="{DynamicResource MaterialDesign.Brush.DataGrid.ComboBoxHover}" />

The line is the same in 5.4.0 and on master at 0877280.

Found with XamlKeys, a static checker for XAML resource keys I'm working on.

Version

5.4.0

Ngôn ngữ chính
C#
Star
16.3k
Fork
3.5k
Merge trung bình
4 giờ 25 phút
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MaterialDesignInXAML/MaterialDesignInXamlToolkit

Tất cả issue của MaterialDesignInXAML/MaterialDesignInXamlToolkit

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.