目录
一 上章回顾
一 上章回顾
二 字段
1 视图集合
2 选中项
3 选中项索引
4 过滤词
5 Button启用状态
三 属性
四 命令
五 总结
六 下章预告
二 GenerateDemoItems
根据通知条消息队列生成导航菜单动态集合
/// <param name="snackbarMessageQueue"></param>
/// <returns></returns>
/// <exception cref="ArgumentNullException"></exception>
private static IEnumerable<DemoItem> GenerateDemoItems(ISnackbarMessageQueue snackbarMessageQueue)
{
//通知条消息队列为空
if (snackbarMessageQueue is null)
throw new ArgumentNullException(nameof(snackbarMessageQueue));
//调色板
yield return new DemoItem(
"Palette",
typeof(PaletteSelector),
new[]
{
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink<PaletteSelector>("Demo View"),
DocumentationLink.DemoPageLink<PaletteSelectorViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PaletteHelper>()
},
selectedIcon: PackIconKind.Palette,
unselectedIcon: PackIconKind.PaletteOutline);
//颜色工具
yield return new DemoItem(
"Color Tool",
typeof(ColorTool),
new[]
{
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink<ColorTool>("Demo View"),
DocumentationLink.DemoPageLink<ColorToolViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PaletteHelper>()
},
selectedIcon: PackIconKind.Eyedropper,
unselectedIcon: PackIconKind.EyedropperVariant);
//按钮
yield return new DemoItem(
"Buttons",
typeof(Buttons),
new[]
{
DocumentationLink.WikiLink("Button-Styles", "Buttons"),
DocumentationLink.DemoPageLink<Buttons>("Demo View"),
DocumentationLink.DemoPageLink<ButtonsViewModel>("Demo View Model"),
DocumentationLink.StyleLink("Button"),
DocumentationLink.StyleLink("PopupBox"),
DocumentationLink.ApiLink<PopupBox>()
},
selectedIcon: PackIconKind.GestureTapHold,
unselectedIcon: PackIconKind.GestureTapHold);
//触发器
yield return new DemoItem(
"Toggles",
typeof(Toggles),
new[]
{
DocumentationLink.DemoPageLink<Toggles>(),
DocumentationLink.StyleLink("ToggleButton", true),
DocumentationLink.StyleLink("CheckBox")
},
selectedIcon: PackIconKind.ToggleSwitch,
unselectedIcon: PackIconKind.ToggleSwitchOffOutline);
//评分控件
yield return new DemoItem(
"Rating Bar",
typeof(RatingBar),
new[]
{
DocumentationLink.DemoPageLink<RatingBar>(),
DocumentationLink.StyleLink("RatingBar"),
DocumentationLink.ApiLink<RatingBar>()
},
selectedIcon: PackIconKind.Star,
unselectedIcon: PackIconKind.StarOutline);
//懒加载字段
yield return new DemoItem(
"Fields",
typeof(Fields),
new[]
{
DocumentationLink.DemoPageLink<Fields>(),
DocumentationLink.StyleLink("TextBox")
},
selectedIcon: PackIconKind.Pencil,
unselectedIcon: PackIconKind.PencilOutline);
//懒加载表单对齐
yield return new DemoItem(
"Fields line up",
typeof(FieldsLineUp),
new[]
{
DocumentationLink.DemoPageLink<FieldsLineUp>()
},
selectedIcon: PackIconKind.PencilBox,
unselectedIcon: PackIconKind.PencilBoxOutline);
//懒加载下拉组合框
yield return new DemoItem(
"ComboBoxes",
typeof(ComboBoxes),
new[]
{
DocumentationLink.DemoPageLink<ComboBoxes>(),
DocumentationLink.StyleLink("ComboBox")
},
selectedIcon: PackIconKind.CheckboxMarked,
unselectedIcon: PackIconKind.CheckboxMarkedOutline);
//懒加载选择器
yield return new DemoItem(
"Pickers",
typeof(Pickers),
new[]
{
DocumentationLink.DemoPageLink<Pickers>(),
DocumentationLink.StyleLink("Clock"),
DocumentationLink.StyleLink("DatePicker"),
DocumentationLink.ApiLink<TimePicker>()
},
selectedIcon: PackIconKind.Clock,
unselectedIcon: PackIconKind.ClockOutline);
//懒加载滑动条
yield return new DemoItem(
"Sliders",
typeof(Sliders),
new[]
{
DocumentationLink.DemoPageLink<Sliders>(),
DocumentationLink.StyleLink("Slider")
},
selectedIcon: PackIconKind.TuneVariant,
unselectedIcon: PackIconKind.TuneVariant);
//懒加载标签
yield return new DemoItem(
"Chips",
typeof(Chips),
new[]
{
DocumentationLink.DemoPageLink<Chips>(),
DocumentationLink.StyleLink("Chip"),
DocumentationLink.ApiLink<Chip>()
},
selectedIcon: PackIconKind.None,
unselectedIcon: PackIconKind.None);
//懒加载排版设计
yield return new DemoItem(
"Typography",
typeof(Typography),
new[]
{
DocumentationLink.DemoPageLink<Typography>(),
DocumentationLink.StyleLink("TextBlock", true)
},
selectedIcon: PackIconKind.FormatSize,
unselectedIcon: PackIconKind.FormatTitle)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
//懒加载卡片
yield return new DemoItem(
"Cards",
typeof(Cards),
new[]
{
DocumentationLink.DemoPageLink<Cards>(),
DocumentationLink.StyleLink("Card"),
DocumentationLink.ApiLink<Card>()
},
selectedIcon: PackIconKind.Card,
unselectedIcon: PackIconKind.CardOutline);
//懒加载图标包
yield return new DemoItem(
"Icon Pack",
typeof(IconPack),
new[]
{
DocumentationLink.DemoPageLink<IconPack>("Demo View"),
DocumentationLink.DemoPageLink<IconPackViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PackIcon>()
},
selectedIcon: PackIconKind.Robot,
unselectedIcon: PackIconKind.RobotOutline,
new IconPackViewModel(snackbarMessageQueue))
{
VerticalScrollBarVisibilityRequirement = ScrollBarVisibility.Disabled
};
//懒加载有色区域
yield return new DemoItem(
"Colour Zones",
typeof(ColorZones),
new[]
{
DocumentationLink.DemoPageLink<ColorZones>(),
DocumentationLink.ApiLink<ColorZone>()
},
selectedIcon: PackIconKind.Subtitles,
unselectedIcon: PackIconKind.SubtitlesOutline);
//懒加载列表控件
yield return new DemoItem(
"Lists",
typeof(Lists),
new[]
{
DocumentationLink.DemoPageLink<Lists>("Demo View"),
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model", "Domain"),
DocumentationLink.StyleLink("ListBox"),
DocumentationLink.StyleLink("ListView")
},
selectedIcon: PackIconKind.FormatListBulletedSquare,
unselectedIcon: PackIconKind.FormatListCheckbox);
//懒加载树形控件
yield return new DemoItem(
"Trees",
typeof(Trees),
new[]
{
DocumentationLink.DemoPageLink<Trees>("Demo View"),
DocumentationLink.DemoPageLink<TreesViewModel>("Demo View Model"),
DocumentationLink.StyleLink("TreeView")
},
selectedIcon: PackIconKind.FileTree,
unselectedIcon: PackIconKind.FileTreeOutline);
//懒加载数据网格
yield return new DemoItem(
"Data Grids",
typeof(DataGrids),
new[]
{
DocumentationLink.DemoPageLink<DataGrids>("Demo View"),
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model", "Domain"),
DocumentationLink.StyleLink("DataGrid")
},
selectedIcon: PackIconKind.ViewGrid,
unselectedIcon: PackIconKind.ViewGridOutline);
//懒加载折叠面板
yield return new DemoItem(
"Expander",
typeof(Expander),
new[]
{
DocumentationLink.DemoPageLink<Expander>(),
DocumentationLink.StyleLink("Expander")
},
selectedIcon: PackIconKind.UnfoldMoreHorizontal,
unselectedIcon: PackIconKind.UnfoldMoreHorizontal);
//懒加载组件框
yield return new DemoItem(
"Group Boxes",
typeof(GroupBoxes),
new[]
{
DocumentationLink.DemoPageLink<GroupBoxes>(),
DocumentationLink.StyleLink("GroupBox")
},
selectedIcon: PackIconKind.TextBoxMultiple,
unselectedIcon: PackIconKind.TextBoxMultipleOutline);
//懒加载菜单工具栏
yield return new DemoItem(
"Menus & Tool Bars",
typeof(MenusAndToolBars),
new[]
{
DocumentationLink.DemoPageLink<MenusAndToolBars>(),
DocumentationLink.StyleLink("Menu"),
DocumentationLink.StyleLink("ToolBar")
},
selectedIcon: PackIconKind.DotsHorizontalCircle,
unselectedIcon: PackIconKind.DotsHorizontalCircleOutline);
//懒加载进度条
yield return new DemoItem(
"Progress Indicators",
typeof(Progress),
new[]
{
DocumentationLink.DemoPageLink<Progress>(),
DocumentationLink.StyleLink("ProgressBar")
},
selectedIcon: PackIconKind.ProgressClock,
unselectedIcon: PackIconKind.ProgressClock);
//懒加载垂直导航栏
yield return new DemoItem(
"Navigation Rail",
typeof(NavigationRail),
new[]
{
DocumentationLink.DemoPageLink<NavigationRail>(),
DocumentationLink.StyleLink("NavigationRail", true),
},
selectedIcon: PackIconKind.NavigationVariant,
unselectedIcon: PackIconKind.NavigationVariantOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
//懒加载水平导航栏
yield return new DemoItem(
"Navigation Bar",
typeof(NavigationBar),
new[]
{
DocumentationLink.DemoPageLink<NavigationBar>(),
DocumentationLink.StyleLink("NavigationBar", true),
},
selectedIcon: PackIconKind.NavigationVariant,
unselectedIcon: PackIconKind.NavigationVariantOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
//懒加载对话框
yield return new DemoItem(
"Dialogs",
typeof(Dialogs),
new[]
{
DocumentationLink.WikiLink("Dialogs", "Dialogs"),
DocumentationLink.DemoPageLink<Dialogs>("Demo View"),
DocumentationLink.DemoPageLink<DialogsViewModel>("Demo View Model", "Domain"),
DocumentationLink.ApiLink<DialogHost>()
},
selectedIcon: PackIconKind.CommentAlert,
unselectedIcon: PackIconKind.CommentAlertOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
//懒加载抽屉
yield return new DemoItem(
"Drawer",
typeof(Drawers),
new[]
{
DocumentationLink.DemoPageLink<Drawers>("Demo View"),
DocumentationLink.ApiLink<DrawerHost>()
},
selectedIcon: PackIconKind.ExpandAll,
unselectedIcon: PackIconKind.ExpandAll);
//懒加载通知条
yield return new DemoItem(
"Snackbar",
typeof(Snackbars),
new[]
{
DocumentationLink.WikiLink("Snackbar", "Snackbar"),
DocumentationLink.DemoPageLink<Snackbars>(),
DocumentationLink.StyleLink("Snackbar"),
DocumentationLink.ApiLink<Snackbar>(),
DocumentationLink.ApiLink<ISnackbarMessageQueue>()
},
selectedIcon: PackIconKind.InformationCircle,
unselectedIcon: PackIconKind.InformationCircleOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
//懒加载转场画面
yield return new DemoItem(
"Transitions",
typeof(Transitions),
new[]
{
DocumentationLink.WikiLink("Transitions", "Transitions"),
DocumentationLink.DemoPageLink<Transitions>(),
DocumentationLink.ApiLink<Transitioner>("Transitions"),
DocumentationLink.ApiLink<TransitionerSlide>("Transitions"),
DocumentationLink.ApiLink<TransitioningContent>("Transitions"),
},
selectedIcon: PackIconKind.TransitionMasked,
unselectedIcon: PackIconKind.Transition);
yield return new DemoItem(
//高度
"Elevation",
typeof(Elevation),
new[]
{
DocumentationLink.DemoPageLink<Elevation>(),
DocumentationLink.StyleLink("Shadows"),
DocumentationLink.SpecsLink("https://material.io/design/environment/elevation.html", "Elevation")
},
selectedIcon: PackIconKind.BoxShadow,
unselectedIcon: PackIconKind.BoxShadow);
}
/// <summary>
/// 菜单过滤函数
/// </summary>
/// <param name="obj">需要过滤动态数据菜单集合</param>
/// <returns>根据关键词筛选显示动态数据菜单集合</returns>
private bool DemoItemsFilter(object obj)
{
//关键词为空返回
if (string.IsNullOrWhiteSpace(_searchKeyword))
{
return true;
}
//返回符合菜单名包括关键词的菜单集合
return obj is DemoItem item
&& item.Name.ToLower().Contains(_searchKeyword!.ToLower());
}
三 GenerateDemoItems详解
1 有效性校验
校验snackbarMessageQueue有效性,若为空,抛出异常
if (snackbarMessageQueue is null)
throw new ArgumentNullException(nameof(snackbarMessageQueue));
2 调色板
yield return new DemoItem(
"Palette",
typeof(PaletteSelector),
new[]
{
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink<PaletteSelector>("Demo View"),
DocumentationLink.DemoPageLink<PaletteSelectorViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PaletteHelper>()
},
selectedIcon: PackIconKind.Palette,
unselectedIcon: PackIconKind.PaletteOutline);
3 颜色工具
yield return new DemoItem(
"Color Tool",
typeof(ColorTool),
new[]
{
DocumentationLink.WikiLink("Brush-Names", "Brushes"),
DocumentationLink.WikiLink("Custom-Palette-Hues", "Custom Palettes"),
DocumentationLink.WikiLink("Swatches-and-Recommended-Colors", "Swatches"),
DocumentationLink.DemoPageLink<ColorTool>("Demo View"),
DocumentationLink.DemoPageLink<ColorToolViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PaletteHelper>()
},
selectedIcon: PackIconKind.Eyedropper,
unselectedIcon: PackIconKind.EyedropperVariant);
4 按钮
yield return new DemoItem(
"Buttons",
typeof(Buttons),
new[]
{
DocumentationLink.WikiLink("Button-Styles", "Buttons"),
DocumentationLink.DemoPageLink<Buttons>("Demo View"),
DocumentationLink.DemoPageLink<ButtonsViewModel>("Demo View Model"),
DocumentationLink.StyleLink("Button"),
DocumentationLink.StyleLink("PopupBox"),
DocumentationLink.ApiLink<PopupBox>()
},
selectedIcon: PackIconKind.GestureTapHold,
unselectedIcon: PackIconKind.GestureTapHold);
5 触发器
yield return new DemoItem(
"Toggles",
typeof(Toggles),
new[]
{
DocumentationLink.DemoPageLink<Toggles>(),
DocumentationLink.StyleLink("ToggleButton", true),
DocumentationLink.StyleLink("CheckBox")
},
selectedIcon: PackIconKind.ToggleSwitch,
unselectedIcon: PackIconKind.ToggleSwitchOffOutline);
6 评分控件
yield return new DemoItem(
"Rating Bar",
typeof(RatingBar),
new[]
{
DocumentationLink.DemoPageLink<RatingBar>(),
DocumentationLink.StyleLink("RatingBar"),
DocumentationLink.ApiLink<RatingBar>()
},
selectedIcon: PackIconKind.Star,
unselectedIcon: PackIconKind.StarOutline);
7 字段
yield return new DemoItem(
"Fields",
typeof(Fields),
new[]
{
DocumentationLink.DemoPageLink<Fields>(),
DocumentationLink.StyleLink("TextBox")
},
selectedIcon: PackIconKind.Pencil,
unselectedIcon: PackIconKind.PencilOutline);
8 表单对齐
yield return new DemoItem(
"Fields line up",
typeof(FieldsLineUp),
new[]
{
DocumentationLink.DemoPageLink<FieldsLineUp>()
},
selectedIcon: PackIconKind.PencilBox,
unselectedIcon: PackIconKind.PencilBoxOutline);
9 下拉组合框
yield return new DemoItem(
"ComboBoxes",
typeof(ComboBoxes),
new[]
{
DocumentationLink.DemoPageLink<ComboBoxes>(),
DocumentationLink.StyleLink("ComboBox")
},
selectedIcon: PackIconKind.CheckboxMarked,
unselectedIcon: PackIconKind.CheckboxMarkedOutline);
10 选择器
yield return new DemoItem(
"Pickers",
typeof(Pickers),
new[]
{
DocumentationLink.DemoPageLink<Pickers>(),
DocumentationLink.StyleLink("Clock"),
DocumentationLink.StyleLink("DatePicker"),
DocumentationLink.ApiLink<TimePicker>()
},
selectedIcon: PackIconKind.Clock,
unselectedIcon: PackIconKind.ClockOutline);
11 滑动条
yield return new DemoItem(
"Sliders",
typeof(Sliders),
new[]
{
DocumentationLink.DemoPageLink<Sliders>(),
DocumentationLink.StyleLink("Slider")
},
selectedIcon: PackIconKind.TuneVariant,
unselectedIcon: PackIconKind.TuneVariant);
12 标签
yield return new DemoItem(
"Chips",
typeof(Chips),
new[]
{
DocumentationLink.DemoPageLink<Chips>(),
DocumentationLink.StyleLink("Chip"),
DocumentationLink.ApiLink<Chip>()
},
selectedIcon: PackIconKind.None,
unselectedIcon: PackIconKind.None);
13 排版设计
yield return new DemoItem(
"Typography",
typeof(Typography),
new[]
{
DocumentationLink.DemoPageLink<Typography>(),
DocumentationLink.StyleLink("TextBlock", true)
},
selectedIcon: PackIconKind.FormatSize,
unselectedIcon: PackIconKind.FormatTitle)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
14 卡片
yield return new DemoItem(
"Cards",
typeof(Cards),
new[]
{
DocumentationLink.DemoPageLink<Cards>(),
DocumentationLink.StyleLink("Card"),
DocumentationLink.ApiLink<Card>()
},
selectedIcon: PackIconKind.Card,
unselectedIcon: PackIconKind.CardOutline);
15 图标包
yield return new DemoItem(
"Icon Pack",
typeof(IconPack),
new[]
{
DocumentationLink.DemoPageLink<IconPack>("Demo View"),
DocumentationLink.DemoPageLink<IconPackViewModel>("Demo View Model"),
DocumentationLink.ApiLink<PackIcon>()
},
selectedIcon: PackIconKind.Robot,
unselectedIcon: PackIconKind.RobotOutline,
new IconPackViewModel(snackbarMessageQueue))
{
VerticalScrollBarVisibilityRequirement = ScrollBarVisibility.Disabled
};
16 有色区域
yield return new DemoItem(
"Colour Zones",
typeof(ColorZones),
new[]
{
DocumentationLink.DemoPageLink<ColorZones>(),
DocumentationLink.ApiLink<ColorZone>()
},
selectedIcon: PackIconKind.Subtitles,
unselectedIcon: PackIconKind.SubtitlesOutline);
17 列表控件
yield return new DemoItem(
"Lists",
typeof(Lists),
new[]
{
DocumentationLink.DemoPageLink<Lists>("Demo View"),
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model", "Domain"),
DocumentationLink.StyleLink("ListBox"),
DocumentationLink.StyleLink("ListView")
},
selectedIcon: PackIconKind.FormatListBulletedSquare,
unselectedIcon: PackIconKind.FormatListCheckbox);
18 树形控件
yield return new DemoItem(
"Trees",
typeof(Trees),
new[]
{
DocumentationLink.DemoPageLink<Trees>("Demo View"),
DocumentationLink.DemoPageLink<TreesViewModel>("Demo View Model"),
DocumentationLink.StyleLink("TreeView")
},
selectedIcon: PackIconKind.FileTree,
unselectedIcon: PackIconKind.FileTreeOutline);
19 数据网络
yield return new DemoItem(
"Data Grids",
typeof(DataGrids),
new[]
{
DocumentationLink.DemoPageLink<DataGrids>("Demo View"),
DocumentationLink.DemoPageLink<ListsAndGridsViewModel>("Demo View Model", "Domain"),
DocumentationLink.StyleLink("DataGrid")
},
selectedIcon: PackIconKind.ViewGrid,
unselectedIcon: PackIconKind.ViewGridOutline);
20 折叠面板
yield return new DemoItem(
"Expander",
typeof(Expander),
new[]
{
DocumentationLink.DemoPageLink<Expander>(),
DocumentationLink.StyleLink("Expander")
},
selectedIcon: PackIconKind.UnfoldMoreHorizontal,
unselectedIcon: PackIconKind.UnfoldMoreHorizontal);
21 组件框
yield return new DemoItem(
"Group Boxes",
typeof(GroupBoxes),
new[]
{
DocumentationLink.DemoPageLink<GroupBoxes>(),
DocumentationLink.StyleLink("GroupBox")
},
selectedIcon: PackIconKind.TextBoxMultiple,
unselectedIcon: PackIconKind.TextBoxMultipleOutline);
22 工具栏
yield return new DemoItem(
"Menus & Tool Bars",
typeof(MenusAndToolBars),
new[]
{
DocumentationLink.DemoPageLink<MenusAndToolBars>(),
DocumentationLink.StyleLink("Menu"),
DocumentationLink.StyleLink("ToolBar")
},
selectedIcon: PackIconKind.DotsHorizontalCircle,
unselectedIcon: PackIconKind.DotsHorizontalCircleOutline);
23 进度条
yield return new DemoItem(
"Progress Indicators",
typeof(Progress),
new[]
{
DocumentationLink.DemoPageLink<Progress>(),
DocumentationLink.StyleLink("ProgressBar")
},
selectedIcon: PackIconKind.ProgressClock,
unselectedIcon: PackIconKind.ProgressClock);
24 垂直导航栏
yield return new DemoItem(
"Navigation Rail",
typeof(NavigationRail),
new[]
{
DocumentationLink.DemoPageLink<NavigationRail>(),
DocumentationLink.StyleLink("NavigationRail", true),
},
selectedIcon: PackIconKind.NavigationVariant,
unselectedIcon: PackIconKind.NavigationVariantOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
25 水平导航栏
yield return new DemoItem(
"Navigation Bar",
typeof(NavigationBar),
new[]
{
DocumentationLink.DemoPageLink<NavigationBar>(),
DocumentationLink.StyleLink("NavigationBar", true),
},
selectedIcon: PackIconKind.NavigationVariant,
unselectedIcon: PackIconKind.NavigationVariantOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
26 对话框
yield return new DemoItem(
"Dialogs",
typeof(Dialogs),
new[]
{
DocumentationLink.WikiLink("Dialogs", "Dialogs"),
DocumentationLink.DemoPageLink<Dialogs>("Demo View"),
DocumentationLink.DemoPageLink<DialogsViewModel>("Demo View Model", "Domain"),
DocumentationLink.ApiLink<DialogHost>()
},
selectedIcon: PackIconKind.CommentAlert,
unselectedIcon: PackIconKind.CommentAlertOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
27 抽屉
yield return new DemoItem(
"Drawer",
typeof(Drawers),
new[]
{
DocumentationLink.DemoPageLink<Drawers>("Demo View"),
DocumentationLink.ApiLink<DrawerHost>()
},
selectedIcon: PackIconKind.ExpandAll,
unselectedIcon: PackIconKind.ExpandAll);
28 通知条
yield return new DemoItem(
"Snackbar",
typeof(Snackbars),
new[]
{
DocumentationLink.WikiLink("Snackbar", "Snackbar"),
DocumentationLink.DemoPageLink<Snackbars>(),
DocumentationLink.StyleLink("Snackbar"),
DocumentationLink.ApiLink<Snackbar>(),
DocumentationLink.ApiLink<ISnackbarMessageQueue>()
},
selectedIcon: PackIconKind.InformationCircle,
unselectedIcon: PackIconKind.InformationCircleOutline)
{
HorizontalScrollBarVisibilityRequirement = ScrollBarVisibility.Auto
};
29 转场画面
yield return new DemoItem(
"Transitions",
typeof(Transitions),
new[]
{
DocumentationLink.WikiLink("Transitions", "Transitions"),
DocumentationLink.DemoPageLink<Transitions>(),
DocumentationLink.ApiLink<Transitioner>("Transitions"),
DocumentationLink.ApiLink<TransitionerSlide>("Transitions"),
DocumentationLink.ApiLink<TransitioningContent>("Transitions"),
},
selectedIcon: PackIconKind.TransitionMasked,
unselectedIcon: PackIconKind.Transition);
30 标高
yield return new DemoItem(
"Elevation",
typeof(Elevation),
new[]
{
DocumentationLink.DemoPageLink<Elevation>(),
DocumentationLink.StyleLink("Shadows"),
DocumentationLink.SpecsLink("https://material.io/design/environment/elevation.html", "Elevation")
},
selectedIcon: PackIconKind.BoxShadow,
unselectedIcon: PackIconKind.BoxShadow);
四 DemoItemsFilter
根据传入用户输入的搜索关键词对DemoItem集合进行过滤,先对关键词有效性进行校验,如果为空返回,否则返回DemoItem集合中包含关键词的搜索结果
private bool DemoItemsFilter(object obj)
{
//关键词为空返回
if (string.IsNullOrWhiteSpace(_searchKeyword))
{
return true;
}
//返回符合菜单名包括关键词的菜单集合
return obj is DemoItem item
&& item.Name.ToLower().Contains(_searchKeyword!.ToLower());
}
五 总结
以上就是MaterialDesign中MainViewModel类中Demo菜单项和关键词过滤的介绍,本文仅仅简单介绍了MainViewModel的示例使用,而实际使用时可以根据需求增添更多菜单项,只需要实现该过滤功能,均能实现快速返回包含关键词的菜单项,从而实现页面间的快速跳转,非常便捷高效。
六 下章预告
下一章我会教大家新的类
博主RaymondLeigh:如果您觉得本文为您提供了结局思路或解决了您的实际问题,麻烦您🙏帮忙点赞、收藏、评论、关注一键四连,您的举手之劳将为我写作提供动力源泉!🤞
print('Hello,RaymondLeigh!') # 每日问候,跟大家问好!
🌞精品前端UI设计专栏:MaterialDesign专栏
💾精品后端数据库专栏:SqlServer专栏
💻精品程序开发专栏 VisualStudio专栏