|
@using System.Reflection
@using Syncfusion.Blazor.SplitButtons
@typeparam TItem
<SfButtonGroup Mode="Syncfusion.Blazor.SplitButtons.SelectionMode.Multiple">
@foreach (var item in DaysOfWeek)
{
PropertyInfo prop = BindValue.GetType().GetProperty(item);
string value = prop.GetValue(BindValue).ToString();
bool boolValue = bool.Parse(value);
<ButtonGroupButton Selected="@boolValue" CssClass="groupbuttonDays">@item.Substring(0, 3)</ButtonGroupButton>
}
</SfButtonGroup>
@code {
[Parameter]
public TItem BindValue { get; set; }
private IEnumerable<string> DaysOfWeek = new List<string>()
{
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
};
}
|
|
<DaysOfTheWeekSelectorComponent BindValue="myClassValues" TItem="MyClass"></DaysOfTheWeekSelectorComponent>
@code {
MyClass myClassValues = new MyClass()
{
Monday = true,
Tuesday = true,
Wednesday = true,
Thursday = true,
Friday = true,
Saturday = false,
Sunday = false
};
public class MyClass
{
public bool Monday { get; set; } = false;
public bool Tuesday { get; set; } = false;
public bool Wednesday { get; set; } = false;
public bool Thursday { get; set; } = false;
public bool Friday { get; set; } = false;
public bool Saturday { get; set; } = false;
public bool Sunday { get; set; } = false;
}
}
|