bug: WinForms ViewModelViewHost does not apply DefaultContent when no view is found

Đang mở Phù hợp với người mới
#4,589 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
85/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
frontend

Hướng nghiên cứu

Đọc src/ReactiveUI.Winforms/ViewModelViewHost.cs, đặc biệt là UpdateContentForViewModel, và so sánh hành vi dự phòng của nó với src/ReactiveUI.Wpf.Shared/Common/ViewModelViewHost.cs. Kiểm tra các bài kiểm thử WinForms cho ViewModelViewHost và bổ sung kiểm thử cho trường hợp view model khác null nhưng không thể phân giải được view. Hoàn thành khi host hiển thị DefaultContent trong trường hợp đó nếu thuộc tính này được thiết lập.

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

Mô tả

ReactiveUI.Winforms.ViewModelViewHost and the WPF ViewModelViewHost handle "no view found" differently. Reported in discussion #3722.

WPF (src/ReactiveUI.Wpf.Shared/Common/ViewModelViewHost.cs, line 168) always falls back to the default:

Content = viewInstance ?? DefaultContent;

WinForms (src/ReactiveUI.Winforms/ViewModelViewHost.cs, UpdateContentForViewModel, lines 206-232) applies DefaultContent only when the view model is null. When the view model is not null but ResolveView returns null (for example after ViewContractObservable changes to a contract that has no registered view), the method returns early and Content keeps the previous view:

var view = _resolveView(ViewLocator ?? GetCurrent(), viewModel, contract);
if (view is null)
{
    return;
}

Expected: when no view resolves, the WinForms host shows DefaultContent (when set), the same as WPF.

Ngôn ngữ chính
C#
Star
8.6k
Fork
1.1k
Merge trung bình
17 giờ 31 phút
Pull request đã merge (30 ngày)
22

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 reactiveui/ReactiveUI

Tất cả issue của reactiveui/ReactiveUI

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.