······首先实现汉堡菜单需要用到splitview 控件 。
relative panel 相对布局控件
panel alignment 边框对齐关系 向上 向左
sibling alignment 同属对齐关系
sibling alignment 同属位置关系
<span style="font-family:Microsoft YaHei;"> <RelativePanel MinHeight="300" Grid.Row="1">
<Rectangle Name="RedRectangle" RelativePanel.AlignRightWithPanel="True" />
<Rectangle RelativePanel.LeftOf="RedRectangle" />
</RelativePanel></span>
uwp-018
split view 创建打开和隐藏的面板
Pane 既能隐藏又能显示的(默认隐藏)
Content 在Pane的下面或者右面 (默认显示)
<span style="font-family:Microsoft YaHei;"><SplitView Name="MySplitView"
CompactPaneLength="50"
IsPaneOpen="False"
DisplayMode="CompactInline"
OpenPaneLength="200" >
<SplitView.Pane>
</SplitView.Pane>
<SplitView.Content>
</SplitView.Content>
</SplitView></span>
Inline 是Pane 被Content的完全掩盖。当Pane展开显示的时候Pane回见Content推出来,Content 依然可见
CompactInline 和之前的比较相像,如果你设置左侧留空,那么就会显示一小块区域在左手边,然后它会显示左侧的图标(前提有图标)
Overlay 和Inline的效果相同,Pane完全隐藏,当显示的时候,Panel将会覆盖Content
CompactOverlay 会留有一块区域突出,当扩展的时候那块区域将会覆盖下面的部分
Open / Close Pane in C#:
MySplitView.IsPaneOpen = !MySplitView.IsPaneOpen;
UWP-19
App > Window > Frame > MainPage
程序里最高级为APP,APP拥有Windows,Windows包含Frame,Frame包含MainPage
导航的方法:Frame属性(可以让我们进入到母框架从而进行导航)
Frame.Navigate(typeof(Page2), additionalParameter);
additionalParameter 可以选择性地附加任意类型的参数
接下来付汇先前页面键入的东西,利用OnNavigatedTo 方法
protected override void OnNavigatedTo(NavigationEventArgs e)
{
value = (string)e.Parameter;
}
可以检查Frame对象调用CanGoBack或者CanGoForward 判断Back Stack是否可以返回或者前进,如果可以调用前进(GoForward)或者后退(GoBack)方法
可以通过在App类下通过声明一个静态的内存空间来创建一个全局变量,可以应对拿中重现back stack的时候需要的值丢失的问题 //听说不建议使用~
UWP-20
<CheckBox Name="MyCheckBox" Content="Agree?" Tapped="MyCheckBox_Tapped" />
CheckBoxResultTextBlock.Text = MyCheckBox.IsChecked.ToString();
<RadioButton Name="YesRadioButton" Content="Yes" GroupName="MyGroup" checked="RadioButton_Checked" />
<RadioButton Name="NoRadioButton" Content="No" GroupName="MyGroup" Checked="RadioButton_Checked" />
使用GroupName将所有同属一个Group的RadioButton归在一起
RadioButtonTextBlock.Text = (bool)YesRadioButton.IsChecked ? "Yes" : "No";
使用三元运算子通过调用RadioButton.IsChecked,如果返回ture(Checked),就复制YES,否者复制No
<ComboBox SelectionChanged="ComboBox_SelectionChanged" >
<ComboBoxItem Content="Fourth" />
<ComboBoxItem Content="Fifth" />
<ComboBoxItem Content="Sixth" IsSelected="True" />
</ComboBox>
IsSelected 表示默认选中
if (ComboBoxResultTextBlock == null) return;
var combo = (ComboBox)sender; //<span style="font-family: 'Microsoft YaHei';">从SelectionChange触发时的事件</span><span style="font-family: 'Microsoft YaHei';">sender </span><span style="font-family: 'Microsoft YaHei';">和 EventArgs e 中得到一个值</span><span style="font-family: 'Microsoft YaHei';">
</span>var item = (ComboBoxItem)combo.SelectedItem; //将Combox中SelectedItem强制转换ComboBoxItem
ComboBoxResultTextBlock.Text = item.Content.ToString();
<ListBox Name="MyListBox" SelectionMode="Multiple" SelectionChanged="ListBox_SelectionChanged">
<ListBoxItem Content="First" />
<ListBoxItem Content="Second" />
<ListBoxItem Content="Third" />
</ListBox>
SelectionMode可以设置为Multiple(可选多个)或者Single(只能一个)
var selectedItems = MyListBox.Items.Cast<ListBoxItem>() //能够找到所有Selected的ListBoxItem(调用SlectedItems大同小异)
.Where(p => p.IsSelected)
.Select(t => t.Content.ToString())
.ToArray();
ListBoxResultTextBlock.Text = string.Join(", ", selectedItems);
<Image Source="Assets/logo.png" Stretch="UniformToFill" />
<ToggleButton Name="MyToggleButton" Content="Premium Option" IsThreeState="True" Click="MyToggleButton_Click" />
IsThreeState有三个状态
ToggleButtonResultTextBlock.Text = MyToggleButton.IsChecked.ToString();
使用 IsChecked 给出True/False或者null
<ToggleSwitch>
<ToggleSwitch.OffContent>
<TextBlock Text="I'm off right now." />
</ToggleSwitch.OffContent>
<ToggleSwitch.OnContent>
<TextBlock Text="I'm on!" />
</ToggleSwitch.OnContent>
</ToggleSwitch>
Character Map找到 Segoe MDL5 Assets.
Hamburger: 
可以运用ListBox和ListBoxItem来设置SplitView中的导航链接