事件选择器
本文描述了用于Blazor的Telerik ColorPicker的可用事件。
OnChange
的OnChange
事件触发时,用户提交他们的选择:
- 应用或取消按钮单击
- 输入键盘按键
- 模糊动作(弹出关闭)
注意OnChange
事件也可能在实际选择的颜色没有改变时触发。
事件类型为EventCallback <对象>
.的OnChange
对象的双向绑定价值
属性。
@*处理ColorPickerOnChange事件*@ @ eventlog
@code {string颜色{get;设置;} string EventLog {get;设置;} async任务ColorPickerOnChange(对象newColor) {EventLog =字符串。Format("The selected color is: {0}", (string)newColor);}}
ValueChanged
的ValueChanged
事件在用户选择新颜色且组件值发生变化时触发。
事件类型为EventCallback <字符串>
.使用ValueChanged
类型的单向绑定价值
在事件处理程序中更新属性和手动值。
@*处理ColorPickerValueChanged事件*@ @code {string颜色{get;设置;} async Task ColorPickerValueChanged(string newColor) {Color = newColor;}}
ViewChanged
的ViewChanged
事件在用户在弹出视图之间切换时触发。
事件类型为EventCallback < ColorPickerView >
.使用ViewChanged
类型的单向绑定视图
在事件处理程序中更新属性和手动值。
@*处理ColorPickerViewChanged事件*@ @code {string Color {get;设置;} ColorPickerView查看{获取;设置;} async Task ColorPickerViewChanged(ColorPickerView newView) {View = newView;}}
OnOpen
的OnOpen
事件在ColorPicker弹出渲染前触发。
事件处理程序接收一个参数ColorPickerOpenEventArgs
对象,该对象包含:
财产 | 描述 |
---|---|
IsCancelled |
设置IsCancelled 财产真正的 取消弹出窗口的打开。 |
@code {private string Color {get;设置;} = "rgb(40,47,137)";//设置IsCancelled为true来取消OnOpen事件参数。IsCancelled = false;}}
OnClose
的OnClose
事件在ColorPicker弹出窗口关闭之前触发。
事件处理程序接收一个参数MultiColumnComboBoxCloseEventArgs
对象,该对象包含:
财产 | 描述 |
---|---|
IsCancelled |
设置IsCancelled 财产真正的 取消弹出窗口的关闭。 |
@*取消基于条件的OnClose事件*@ @code{私有字符串颜色{get;设置;} = "rgba(40,47,137,0)";private void OnColorPickerPopupClose(ColorPickerCloseEventArgs){//取消基于条件的OnClose事件如果(Color == "rgba(255,255,255,0)") {args。IsCancelled = true;}}}