feature: Bind validation to non-string view properties
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu từ các API BindValidation và OneWayBind hiện có, sử dụng các chữ ký generic được đề xuất và phương án thay thế WhenAnyObservable làm ngữ cảnh hành vi. Xác định cách trạng thái validation được ánh xạ tới một thuộc tính view không phải string thông qua selector; hoàn thành khi overload được yêu cầu hỗ trợ binding kiểu Color mà vẫn giữ nguyên hành vi validation hiện có.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
Not related to a problem.
Describe the solution you'd like
So what I'm trying to do is change the color of control in my view based on the validation state of a validation helper. The control does have an error property or something similar, and I do not want to show an inline error message anyway for this particular situation. What I would like to be able to do is something like this:
this.BindValidation(ViewModel, viewModel => viewModel.Property, view => view.Control.Color,
validationState => validationState.IsValid ? Color.Green : Color.Red);
This would similar to the overload of the OneWayBind function that allows you to bind between types like so:
this.OneWayBind(ViewModel, viewModel => vm.BoolProperty, view => view.Control.Color,
boolProperty => boolProperty ? Color.Green : Color.Red);
Describe alternatives you've considered
Currently this is how I'm achieving the same effect:
this.WhenAnyObservable(v => v.ViewModel.PropertyValidator.ValidationChanged)
.Select(validationState => validationState.IsValid ? Color.Green : Color.Red)
.BindTo(this, v => v.Control.Color);
This works, and I don't necessarily hate it, but I would prefer the proposed form for brevity and to match with the rest of my simple bindings.
Describe suggestions on how to achieve the feature
I'm not sure exactly how to make this work or I probably just would have made done it and made PR, but I think the signatures of the overloads for such a change would look something like this:
public static IDisposable BindValidation<TView, TViewModel, TViewModelProperty, TViewProperty>(
this TView view,
TViewModel? viewModel,
Expression<Func<TViewModel, TViewModelProperty>> viewModelProperty,
Expression<Func<TView, TViewProperty>> viewProperty,
Expression<Func<IValidationState, TViewProperty>> selector,
IValidationTextFormatter<string>? formatter = null)
where TView : IViewFor<TViewModel>
where TViewModel : class, IReactiveObject, IValidatableViewModel
and this:
public static IDisposable BindValidation<TView, TViewModel, TViewProperty>(
this TView view,
TViewModel? viewModel,
Expression<Func<TViewModel?, ValidationHelper?>> viewModelHelperProperty,
Expression<Func<TView, TViewProperty>> viewProperty,
Expression<Func<IValidationState, TViewProperty>> selector,
IValidationTextFormatter<string>? formatter = null)
where TView : IViewFor<TViewModel>
where TViewModel : class, IReactiveObject, IValidatableViewModel
Additional context
- Ngôn ngữ chính
- C#
- Star
- 273
- Fork
- 30
- Merge trung bình
- 20 giờ 35 phút
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của reactiveui/ReactiveUI.Validation
-
Dependency DashboardĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 20/100
reactiveui/ReactiveUI.Validation#634 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
reactiveui/ReactiveUI.Validation#511 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
reactiveui/ReactiveUI.Validation#414 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feature: add benchmarksĐang mởPerformance
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
reactiveui/ReactiveUI.Validation#117 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của reactiveui/ReactiveUI.Validation
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
:watch: Not Triaged advanced-concepts/subsvc dotnet-csharp/svc
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement no-stack-trace
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
greenshot/greenshot#1618 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
microsoft/aspire.dev#1962 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày