我正在使用 MudBlazor,具体来说MudSelect。我想显示该Name属性,但将该Id属性保存在 Value 中。以下正在工作。
<MudSelect T="int" Label="Assigned Group" Variant="Variant.Outlined" Required="true" RequiredError="An Assigned Group is required." @bind-Value="newTask.GroupId" AdornmentIcon="@Icons.Filled.Group">
@foreach (var group in Groups)
{
<MudSelectItem Value="@group.Id">@group.Name</MudSelectItem>
}
</MudSelect>
Run Code Online (Sandbox Code Playgroud)
但是,随着选项数量开始增长,沿着Select List. 我不知道如何在 中使用它MudSelect。在使用 时MudAutocomplete,它为我提供了搜索功能,但我不知道如何将Id与所选的关联起来Name。虽然,由于我的Name, 是独一无二的,所以我可以对 进行一些处理来submit获取Id,但我想防止额外的处理
将样式应用于 MudBlzaor 组件(特别是表格)的正确方法是怎样的?:
\n代码
\n<MudTable>\n <HeaderContent>\n <MudTh> Some Random Header</MudTh>\n ...\n </HeaderContent>\n <RowTemplate>\n <MudTd> Some Random Content</MudTd>\n </RowTemplate>\n</MudTable>\n\nRun Code Online (Sandbox Code Playgroud)\n问题
\n1:我可以以任何方式应用样式吗?它将应用于组件内的所有元素,在本例中应用样式,<HeaderContent>所有元素<MudTh>都会有它。
2:如何使用Class属性?我已经使用了它,<MudTh>但它不起作用(我什至在检查模式下找不到它,它应用于元素,但不会出现在样式部分中)。
PS:我可以将内联样式应用于元素,但这似乎既不可行也不可扩展。
\n编辑
\n任务详细信息.razor
\n<MudTable>\n <HeaderContent>\n <MudTh Class="tableHeader"><MudTableSortLabel SortBy="new Func<TaskItemDisplayModel, object>(x => x.Name)"></MudTableSortLabel>Name</MudTh>\n @*<MudTh Style="font-weight:bold;"><MudTableSortLabel SortBy="new Func<TaskItemDisplayModel, object>(x => x.Name)"></MudTableSortLabel>Name</MudTh> THIS WORKS*@\n\nRun Code Online (Sandbox Code Playgroud)\n任务详细信息.razor.css
\n...\n.tableHeader {\n font-weight:bold;\n}\n...\nRun Code Online (Sandbox Code Playgroud)\n\n注意\n我可以在其他非 MudBlazor 元素上使用类。
\nI'm using Blazor's default NavMenu Component, and its toggler won't appear on wide screens (>640px; it works on smaller ones).
Analysing the css:
There is a display:none.
What I've tried
Adding the following code to site.css:
@media (min-width: 768px) {
.navbar-toggler {
display: normal;
}
}
Run Code Online (Sandbox Code Playgroud)
Adding a static inline style reference with display:normal!important; (will appear crossed and overwritten by the image above).
Changing none to normal in the browser (While the icon will appear, it's functions: collapsing the navmenu …
这里:SimilarQuestion,公认的答案是使用@与否是基于审美原因。
但在我的用例中似乎存在差异:
<MudSelect T="int" Label="Add to meeting:" Variant="Variant.Outlined" @bind-Value="SelectedTaskId">
@foreach (var task in TasksNotInMeeting)
{
<MudSelectItem Value="task.Id">task.Name</MudSelectItem>
}
</MudSelect>
Run Code Online (Sandbox Code Playgroud)
使用task.Name而不是@task.Name使输出为“task.Name”。不过,task.Id 似乎有效。当我写这篇文章时,我想这可能是因为我在 html 区域,对吗?