win10 UWP Controls by function
最后更新于:2022-04-01 20:23:46
Windows的XAML UI框架提供了很多控件,支持用户界面开发库。其中一些有可视化,一些布局。
一些控件例子:[https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlUIBasics](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlUIBasics)
我现在做的一个中文版的,很多都是照着微软写,除了注释
我们先学微软做一个简单的frame,新建Page,
里面放title和跳转页
~~~
public class page
{
public page()
{
}
///
/// 跳转页
///
public Type navigate
{
set
{
_navigate = value;
}
get
{
return _navigate;
}
}
///
/// 页面名
///
public string title
{
set
{
_title = value;
}
get
{
return _title;
}
}
private Type _navigate;
private string _title;
}
~~~
我们需要把所有页放到一个类,本来这个类可以不弄,直接放Page
使用索引
最后我还是想给宝资通打广告
弄了一个类,本来应该叫page管理器,我叫baozitong
输入title返回type
~~~
public static Type page(string title)
{
foreach (var temp in _page)
{
if (temp.title == title)
{
return temp.navigate;
}
}
return null;
}
public static List _page
{
set;
get;
}=new List()
{
new page()
{
title = "appbar",
navigate = typeof(appbar)
}
};
~~~
每次添加page可以在baozitong._page new page
界面splitview
~~~
~~~
~~~
private void nagivate(object sender, SelectionChangedEventArgs e)
{
//跳转navigate
frame.Navigate(((sender as ListView).SelectedItem as page).navigate);
}
~~~
## Appbars and commands
### App bar
用于显示应用程序特定命令的工具栏。
### App bar button
使用app bar风格按钮
一个简单的按钮
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763769cc39.jpg)
我们可以加上内容
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076376ae0f0.jpg)
我们可以在按钮加浮出
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076376bf84a.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076376d2dd9.jpg)
### App bar separator
命令栏中的命令组。
如果我们有很多按钮,我们可以使用
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076376e656a.jpg)
### App bar toggle button
开关命名命令栏
### Command bar
一种专门处理命令按钮栏按钮
我们把刚才的按钮放在``
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763770263a.jpg)
我们也看到最后的按钮,如果有一些用不到,但是有用
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637714cf0.jpg)
## Buttons
### Button
响应用户输入和点击事件。
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637725931.jpg)
按钮点击可以使用`X:Bind`
### Hyperlink
超链接
~~~
博客发在csdn ,没有授权红黑转载,没有授权推酷转载
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637749283.jpg)
### Repeat button
用户点击不停响应。
## Collection/data controls
### Flip view
幻灯片播放
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637761d18.jpg)
[http://www.cnblogs.com/Damai-Pang/p/5201206.html](http://www.cnblogs.com/Damai-Pang/p/5201206.html)
### Grid view
行列布局,可以水平滚动控件。
### Items control
提供UI指定数据模板
### List view
在一个列表上的项目的集合,可以垂直滚动控件
我们做一个viewmodel
~~~
public class viewmodel : notify_property
{
public viewmodel()
{
}
}
~~~
我们依列表
~~~
public ObservableCollection lindexi
{
set;
get;
} = new ObservableCollection()
{
"林德熙",
"csdn"
};
~~~
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076377c1426.jpg)
## Date and time controls
### Calendar date picker
日历日期选择器
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076377d303b.png)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076377e7c3c.jpg)
### Calendar view
日程表,让用户选择日期
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637802a3f.jpg)
### Time picker
用户选择一个时间
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076378123aa.jpg)
## Flyouts
### Flyout
显示一条消息
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763782352e.jpg)
### Menu flyout
暂时显示命令或列出选项给用户选择
~~~
~~~
### Popup menu
弹出自己写的菜单
### Tooltip
提示
~~~
~~~
## Images
### Image
图片
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076378374cc.jpg)
如果需要gif可以 [http://www.songsong.org/post/2015/10/11/ImageLib.html](http://www.songsong.org/post/2015/10/11/ImageLib.html)
## Graphics and ink
### InkCanvas
~~~
~~~
手写
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637866f95.jpg)
保存文件可以去edi.wang
### Shapes
椭圆,矩形、线、贝塞尔曲线路径
~~~
~~~
~~~
~~~
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763787bc24.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763788eb2e.jpg)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076378a0849.jpg)
## Layout controls
### Border
边框
### Canvas
画板
### Grid
网格布局
### StackPanel
堆放布局
### Scroll viewer
滚动视图
~~~
~~~
### Viewbox
可以改变内容的长宽
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076378ae828.jpg)
## Media controls
### Media element
播放视频
其实我之前用它播放音频[https://github.com/lindexi/Markdown](https://github.com/lindexi/Markdown)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763732677b.jpg)
~~~
private async void speech(string str, MediaElement media_element)
{
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
SpeechSynthesisStream stream = await synthesizer.SynthesizeTextToStreamAsync(str);
media_element.SetSource(stream, stream.ContentType);
//http://blog.csdn.net/lindexi_gd
media_element.Play();
}
~~~
还有没写好,全屏出问题,可以来我博客[http://blog.csdn.net/lindexi_gd](http://blog.csdn.net/lindexi_gd)之后找到解决将会写一个,可能是预览版,在真机就出错
### MediaTransportControls
控制播放
## Navigation
### Hub
全景视图控件
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076378cc3cb.jpg)
## Progress controls
### Progress bar
进度条
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763793771c.jpg)
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_570763796ccd0.jpg)
### Progress ring
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_57076379de819.jpg)
## Text controls
### Auto suggest box
~~~
~~~
需要在后台[https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlAutoSuggestBox](https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/XamlAutoSuggestBox)
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637a35447.jpg)
### Password box
密码输入
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637a43b9a.jpg)
### Rich edit box
~~~
~~~
### Text block
简单输出文本
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637a53b11.jpg)
### Text box
用户输入文本
~~~
~~~
![](https://docs.gechiui.com/gc-content/uploads/sites/kancloud/2016-04-08_5707637a652ba.jpg)
博客:[http://blog.csdn.net/lindexi_gd](http://blog.csdn.net/lindexi_gd)
现在委托csdn维权,没有授权的网站不要转载
原文[https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/controls-by-function](https://msdn.microsoft.com/en-us/windows/uwp/controls-and-patterns/controls-by-function)
';