File tree Expand file tree Collapse file tree 2 files changed +83
-39
lines changed
src/BootstrapBlazor/Components/Dropdown Expand file tree Collapse file tree 2 files changed +83
-39
lines changed Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements.
2+ // The .NET Foundation licenses this file to you under the Apache 2.0 License
3+ // See the LICENSE file in the project root for more information.
4+ // Maintainer: Argo Zhang([email protected] ) Website: https://www.blazor.zone 5+
6+ namespace BootstrapBlazor . Components ;
7+
8+ /// <summary>
9+ /// DropdownItem 组件
10+ /// </summary>
11+ public class DropdownItem : ComponentBase , IDropdownItem , IDisposable
12+ {
13+ /// <summary>
14+ /// 获得/设置 显示文本
15+ /// </summary>
16+ [ Parameter ]
17+ public string ? Text { get ; set ; }
18+
19+ /// <summary>
20+ /// 获得/设置 图标
21+ /// </summary>
22+ [ Parameter ]
23+ public string ? Icon { get ; set ; }
24+
25+ /// <summary>
26+ /// 获得/设置 是否被禁用 默认 false 优先级低于 <see cref="OnDisabledCallback"/>
27+ /// </summary>
28+ [ Parameter ]
29+ public bool Disabled { get ; set ; }
30+
31+ /// <summary>
32+ /// 获得/设置 是否被禁用回调方法 默认 null 优先级高于 <see cref="Disabled"/>
33+ /// </summary>
34+ [ Parameter ]
35+ public Func < DropdownItem , bool > ? OnDisabledCallback { get ; set ; }
36+
37+ /// <summary>
38+ /// 获得/设置 点击回调方法 默认 null
39+ /// </summary>
40+ [ Parameter ]
41+ public Func < Task > ? OnClick { get ; set ; }
42+
43+ [ CascadingParameter ]
44+ [ NotNull ]
45+ private List < IDropdownItem > ? Items { get ; set ; }
46+
47+ /// <summary>
48+ /// <inheritdoc/>
49+ /// </summary>
50+ protected override void OnInitialized ( )
51+ {
52+ base . OnInitialized ( ) ;
53+
54+ Items . Add ( this ) ;
55+ }
56+
57+ private bool disposedValue ;
58+
59+ /// <summary>
60+ /// 释放资源方法
61+ /// </summary>
62+ /// <param name="disposing"></param>
63+ protected virtual void Dispose ( bool disposing )
64+ {
65+ if ( ! disposedValue )
66+ {
67+ if ( disposing )
68+ {
69+ Items . Remove ( this ) ;
70+ }
71+ disposedValue = true ;
72+ }
73+ }
74+
75+ /// <summary>
76+ /// <inheritdoc/>
77+ /// </summary>
78+ public void Dispose ( )
79+ {
80+ Dispose ( true ) ;
81+ GC . SuppressFinalize ( this ) ;
82+ }
83+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments