如何在MudDatePicker组件中排除选择,例如:星期一和星期五?

huangapple go评论71阅读模式
英文:

How to exclude from the selection, for example: Monday and Friday in the MudDatePicker component?

问题

I have problem with Mudblazor framework, because i can't find solution to my problem
如何在MudDatePicker组件中排除选择,例如:星期一和星期五?
我使用Mudblazor框架。
Kind regards,
Lukasz

英文:

I have problem with Mudblazor framework, because i can't find solution to my problem
How to exclude from the selection, for example: Monday and Friday in the MudDatePicker component?
I using Mudblazor framework.

Kind regards,
Lukasz

答案1

得分: 0

你可以在你的 MudDatePicker 组件上使用 IsDateDisabledFunc 属性:

<MudDatePicker @bind-Date="SelectedDate"
               IsDateDisabledFunc="CheckIsDateDisabled" />

@code {
private DateTime? SelectedDate { get; set; }
private bool CheckIsDateDisabled(DateTime date) => date.DayOfWeek is DayOfWeek.Monday or DayOfWeek.Friday;
}

英文:

You can use the IsDateDisabledFunc attribute on your MudDatePicker component:

<MudDatePicker @bind-Date="SelectedDate"
               IsDateDisabledFunc="CheckIsDateDisabled" />

@code {
    private DateTime? SelectedDate { get; set; }
    private bool CheckIsDateDisabled(DateTime date) => date.DayOfWeek is DayOfWeek.Monday or DayOfWeek.Friday;
}

huangapple
  • 本文由 发表于 2023年5月18日 03:13:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76275502.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定