diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor b/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor index 51f936661..4b3cf8a69 100644 --- a/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor +++ b/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor @@ -4,28 +4,28 @@
- +
- +
- +
- +
- +
- +
- +
- +
diff --git a/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor.cs b/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor.cs index 736582e32..f0256f075 100644 --- a/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor.cs +++ b/src/BootstrapBlazor.Shared/Pages/Samples/Cascaders.razor.cs @@ -84,7 +84,7 @@ namespace BootstrapBlazor.Shared.Pages { new EventItem() { - Name = "OnValueChanged", + Name = nameof(Cascader.OnSelectedItemChanged), Description="级联选择选项改变时触发此事件", Type ="Func" } @@ -148,4 +148,4 @@ namespace BootstrapBlazor.Shared.Pages } }; } -} \ No newline at end of file +} diff --git a/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs b/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs index 533e60940..de2ba3241 100644 --- a/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs +++ b/src/BootstrapBlazor/Components/Cascader/Cascader.razor.cs @@ -56,7 +56,7 @@ namespace BootstrapBlazor.Components /// ValueChanged 方法 /// [Parameter] - public Func? OnValueChanged { get; set; } + public Func? OnSelectedItemChanged { get; set; } [Inject] [NotNull] @@ -190,7 +190,7 @@ namespace BootstrapBlazor.Components CurrentValueAsString = value; - if (OnValueChanged != null) await OnValueChanged.Invoke(_selectedItems.ToArray()); + if (OnSelectedItemChanged != null) await OnSelectedItemChanged.Invoke(_selectedItems.ToArray()); } private void RefreshDisplayValue() => _displayText = string.Join("/", _selectedItems.Select(item => item.Text)); diff --git a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs index 808def6a9..9a6c07e89 100644 --- a/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs +++ b/src/BootstrapBlazor/Components/Dropdown/Dropdown.razor.cs @@ -60,7 +60,7 @@ namespace BootstrapBlazor.Components /// /// /// - private string? ActiveItem(SelectedItem item) => CssBuilder.Default("dropdown-item") + protected string? ActiveItem(SelectedItem item) => CssBuilder.Default("dropdown-item") .AddClass("active", () => item.Value == CurrentValueAsString) .Build(); @@ -81,7 +81,7 @@ namespace BootstrapBlazor.Components /// /// 下拉框选项点击时调用此方法 /// - private async Task OnItemClick(SelectedItem item) + protected async Task OnItemClick(SelectedItem item) { if (!item.IsDisabled) { diff --git a/src/BootstrapBlazor/Components/Toggle/ToggleBase.cs b/src/BootstrapBlazor/Components/Toggle/ToggleBase.cs index 6c6994fc8..58e5a03b0 100644 --- a/src/BootstrapBlazor/Components/Toggle/ToggleBase.cs +++ b/src/BootstrapBlazor/Components/Toggle/ToggleBase.cs @@ -62,12 +62,6 @@ namespace BootstrapBlazor.Components [Parameter] public Color Color { get; set; } = Color.Success; - /// - /// - /// - [Parameter] - public Func? OnValueChanged { get; set; } - /// /// 点击控件时触发此方法 /// diff --git a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs index 8ba8f1a3b..c8e1e2bc9 100644 --- a/src/BootstrapBlazor/Components/Validate/ValidateBase.cs +++ b/src/BootstrapBlazor/Components/Validate/ValidateBase.cs @@ -82,6 +82,10 @@ namespace BootstrapBlazor.Components { _ = ValueChanged.InvokeAsync(value); } + if (OnValueChanged != null) + { + _ = OnValueChanged.Invoke(value); + } if (!SkipValidate && FieldIdentifier != null) { EditContext?.NotifyFieldChanged(FieldIdentifier.Value); @@ -145,6 +149,12 @@ namespace BootstrapBlazor.Components } } + /// + /// 获得/设置 Value 改变时回调方法 + /// + [Parameter] + public Func? OnValueChanged { get; set; } + /// /// 获得/设置 类型转化失败格式化字符串 默认为 null ///