- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在开发 UWP 应用程序,此应用程序包含一些产品类别,并在此类别中创建另一个产品列表,这最多 3 级导航。
For Example
最佳答案
我现在正在开发一个涉及使用此类导航的 UWP 应用程序。让我为您介绍基本代码,然后您可以根据需要进行修改。
所以,我的 XAML 看起来像这样:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="50"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel Grid.Row="0" Background="Blue">
<Button x:Name="button" Content="" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Width="50" Height="50" Foreground="White" BorderBrush="{x:Null}" Background="{x:Null}" FontFamily="Segoe MDL2 Assets" RelativePanel.AlignLeftWithPanel="True" Click="button_Click"/>
<TextBlock x:Name="textBlock" TextWrapping="Wrap" Text="Your App Name" Foreground="#FFF7F7F7" RelativePanel.AlignVerticalCenterWithPanel="True" RelativePanel.AlignRightWith="" RelativePanel.RightOf="button" Margin="10,0,0,0" FontSize="22"/>
</RelativePanel>
<SplitView x:Name="MySplitView" IsPaneOpen="False" OpenPaneLength="220" Grid.Column="0" PaneBackground="SkyBlue" Grid.Row="1" d:LayoutOverrides="LeftMargin, RightMargin, TopMargin, BottomMargin">
<SplitView.Pane>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<ListView x:Name="_one" Margin="10,0">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Tapped="TextBlock_Tapped" Text="{Binding}" SelectionHighlightColor="{x:Null}" Foreground="White"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="_two" Grid.Column="1" Margin="10,0">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Tapped="TextBlock_Tapped_1" Text="{Binding}" SelectionHighlightColor="{x:Null}" Foreground="White"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ListView x:Name="_three" Grid.Column="2" Margin="10,0">
<ListView.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" SelectionHighlightColor="{x:Null}" Foreground="White"/>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</SplitView.Pane>
<Grid>
<TextBlock Text="Your Content" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="36"/>
</Grid>
</SplitView>
</Grid>
如您所见,我有一个名为“MySplitView”的 SplitView 控件。
它有一个 Pane 和一个网格。
Pane 包含导航,而网格包含应用程序的内容。
Pane 分为三列,每列包含 ListView。
三个 ListView 包含一个简单的 TextBlock 控件来显示项目,以及该 TextBlock 控件上的一个单击事件以显示基于该项目的第二个或第三个子列表。
后面的代码是:
public List<string> mainList;
public List<SubItem> secondList, thirdList;
public BlankPage1()
{
this.InitializeComponent();
mainList = new List<string>();
mainList.Add("Main Item 1");
mainList.Add("Main Item 2");
mainList.Add("Main Item 3");
mainList.Add("Main Item 4");
mainList.Add("Main Item 5");
secondList = new List<SubItem>();
secondList.Add(new SubItem { mainItem = "Main Item 1", subItem = "Second Item 1" });
secondList.Add(new SubItem { mainItem = "Main Item 1", subItem = "Second Item 2" });
secondList.Add(new SubItem { mainItem = "Main Item 1", subItem = "Second Item 3" });
secondList.Add(new SubItem { mainItem = "Main Item 2", subItem = "Second Item 1" });
secondList.Add(new SubItem { mainItem = "Main Item 2", subItem = "Second Item 2" });
secondList.Add(new SubItem { mainItem = "Main Item 2", subItem = "Second Item 3" });
secondList.Add(new SubItem { mainItem = "Main Item 3", subItem = "Second Item 1" });
secondList.Add(new SubItem { mainItem = "Main Item 3", subItem = "Second Item 2" });
secondList.Add(new SubItem { mainItem = "Main Item 3", subItem = "Second Item 3" });
secondList.Add(new SubItem { mainItem = "Main Item 4", subItem = "Second Item 1" });
secondList.Add(new SubItem { mainItem = "Main Item 4", subItem = "Second Item 2" });
secondList.Add(new SubItem { mainItem = "Main Item 4", subItem = "Second Item 3" });
secondList.Add(new SubItem { mainItem = "Main Item 5", subItem = "Second Item 1" });
secondList.Add(new SubItem { mainItem = "Main Item 5", subItem = "Second Item 2" });
secondList.Add(new SubItem { mainItem = "Main Item 5", subItem = "Second Item 3" });
thirdList = new List<SubItem>();
thirdList.Add(new SubItem { mainItem = "Second Item 1", subItem = "Third Item 1" });
thirdList.Add(new SubItem { mainItem = "Second Item 1", subItem = "Third Item 2" });
thirdList.Add(new SubItem { mainItem = "Second Item 1", subItem = "Third Item 3" });
thirdList.Add(new SubItem { mainItem = "Second Item 1", subItem = "Third Item 4" });
thirdList.Add(new SubItem { mainItem = "Second Item 2", subItem = "Third Item 1" });
thirdList.Add(new SubItem { mainItem = "Second Item 2", subItem = "Third Item 2" });
thirdList.Add(new SubItem { mainItem = "Second Item 2", subItem = "Third Item 3" });
thirdList.Add(new SubItem { mainItem = "Second Item 2", subItem = "Third Item 4" });
thirdList.Add(new SubItem { mainItem = "Second Item 3", subItem = "Third Item 1" });
thirdList.Add(new SubItem { mainItem = "Second Item 3", subItem = "Third Item 2" });
thirdList.Add(new SubItem { mainItem = "Second Item 3", subItem = "Third Item 3" });
thirdList.Add(new SubItem { mainItem = "Second Item 3", subItem = "Third Item 4" });
_one.ItemsSource = mainList;
}
public class SubItem
{
public string mainItem { get; set; }
public string subItem { get; set; }
}
private void TextBlock_Tapped(object sender, TappedRoutedEventArgs e)
{
//Main Item is clicked
//To show Second Item list
TextBlock tb = sender as TextBlock;
List<string> seconditems = new List<string>();
foreach(SubItem s in secondList)
{
if(s.mainItem == tb.Text)
{
seconditems.Add(s.subItem);
}
}
this._two.ItemsSource = seconditems;
this._two.UpdateLayout();
//In case the user clicks the Main Item when already Third list has items
_three.ItemsSource = null;
this._three.UpdateLayout();
//Set OpenPaneLength manually so Items look nice
MySplitView.OpenPaneLength = _one.Width + _two.Width + 50;
this.MySplitView.UpdateLayout();
}
private void button_Click(object sender, RoutedEventArgs e)
{
//To Open Close SplitView
MySplitView.IsPaneOpen = !MySplitView.IsPaneOpen;
}
private void TextBlock_Tapped_1(object sender, TappedRoutedEventArgs e)
{
// Secondary Item is clicked
// To show thirdlist
TextBlock tb = sender as TextBlock;
List<string> thirditems = new List<string>();
foreach (SubItem s in thirdList)
{
if (s.mainItem == tb.Text)
{
thirditems.Add(s.subItem);
}
}
this._three.ItemsSource = thirditems;
this._three.UpdateLayout();
//Set OpenPaneLength manually so Items look nice
MySplitView.OpenPaneLength = _one.Width + _two.Width + _three.Width+ 50;
this.MySplitView.UpdateLayout();
}
希望这对您有所帮助。
祝你有美好的一天。
问候,
劳纳克·帕特尔
关于c# - UWP App 中的垂直多级导航菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38095957/
我想对齐输入,它有两个标签和一个没有任何标签的按钮,以便它们都在同一级别。 这是期望的效果: 这是我到目前为止得到的: 我通过在按钮前添加带有空白空间的标签,设法让它看起来像我想要的样子,但这并不理想
您好,我有一个关于 JavaFX 的问题。我担心答案是剥皮,我对此一无所知,但这里是。 我想在 JavaFX 中制作 Accordion/TabPane 交叉。我将尝试用文字解释自己,但在下面我已经包
这可能被认为是一个低俗的问题。然而,我还没有找到任何代码,也没有找到任何讨论如何用我的编程语言 C 来解决这个问题的论坛。已经进行了大量的尝试,并且最终都以实际上“硬编码”新数组而告终。 我正在尝试垂
我有以下代码: public Frame() { super(); setVisible(true); setDefaultCloseOperation(JFrame.EXIT
是否可以将 UIModalTransitionStyleFlipHorizontal 修改为垂直而不是水平? 我通常会使用 CATransition 来执行此操作,但该方法需要将一个 UIView
我有一个 ios5 导航的想法,我正在一个应用程序上做,我认为从 SOF 那里得到一些关于我的想法的建设性批评是明智的。 p> 想法: UIView 包含 6 个左右垂直堆叠的按钮 UIButtons
我正在努力进行一些 iOS 开发,我希望有人能够帮助我提出建议。我想实现一堆看起来像一副纸牌的 UIView。用户应该能够通过触摸刷出“卡片”。我想到了带有 pagingEnabled 的 UIScr
我想创建一个包含四张图片的入口页面作为指向其他页面的链接。但我希望这些图片显示在显示器的中间(垂直和水平)。我已经尝试了很多事情,但我做对了。我什至无法以任何方式垂直对齐图片(例如底部,您将在代码中看
我有代码在 div 的底部创建一个元素作为向下的“箭头/指针”。 我需要这样写,以便“箭头/指针”指向左侧 当前代码 - HTML 掩码 css 在 fiddle 中 https://j
下面的代码将焦点放在中间的 div 上,但该 div 出现在窗口的底部。如何使该 div 居中,使其显示在窗口的中心[垂直],而不设置固定位置。 $(function(){ $("#focus
这个问题在这里已经有了答案: Vertical Align Center in Bootstrap 4 [duplicate] (20 个答案) 关闭 4 年前。 我创建了一个由两列组成的结构,第一
演示:http://jsfiddle.net/vpH8r/2/ 我在上面创建了一个 jfiddle,试图让垂直滑动正常工作。 当前的问题是 slider 标签不会移动,并且不会出现从顶部到底部的干净滑
我正在尝试在 javascript 中创建一个垂直 slider 小部件。我不是在寻找任何插件或库,我正在尝试查看如何使用纯 javascript 完成它。我想我大概明白了。 请在此处查看到目前为止已
我正在尝试创建一个响应式导航列表,并将图像置于页面列表的中心 我已经设法接近那个,但是图像比列表更靠前。 我想像这样得到它,但似乎无法弄清楚。 任何帮助将不胜感激! 代码:https://jsfidd
有人可以帮我将导航栏居中,使其在页面上垂直居中吗? 我希望导航栏中央的链接位于顶部,而不是像现在这样向左浮动。 提前致谢 Toggle navigation
我想垂直、水平转换图像,并使用 javascript 缩放图像。目前我设法使调整大小的图像起作用,但它看起来不正确。我正在尝试使用类似于 Transform image 的东西.调整垂直移动条时,图像
这可能是一个问题,但要求太多,但我已经达到了我的极限。 我有这段 ( http://jsfiddle.net/3whTa/) CSS,它创建了一个箭头水平面包屑导航。 我想做的是将其转换为垂直。就像箭
我正在使用 opencv 进行非常简单的操作,但我无法理解为什么会出现此错误/问题。图像被操作到图像的一半(垂直)。 Mat img = imread("/Users/tanmoy/Documents
我想知道是否有人有任何技术来定位 css 生成的内容。例如: .block { height: 150px; width: 150px; border: 1px solid black;
关闭。这个问题需要更多 focused .它目前不接受答案。 想要改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭3年前。 Improve this que
我是一名优秀的程序员,十分优秀!