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风格按钮
一个简单的按钮
~~~
~~~

我们可以加上内容
~~~
~~~

我们可以在按钮加浮出
~~~
~~~


### App bar separator
命令栏中的命令组。
如果我们有很多按钮,我们可以使用
~~~
~~~

### App bar toggle button
开关命名命令栏
### Command bar
一种专门处理命令按钮栏按钮
我们把刚才的按钮放在``
~~~
~~~

我们也看到最后的按钮,如果有一些用不到,但是有用
~~~
~~~

## Buttons
### Button
响应用户输入和点击事件。
~~~
~~~

按钮点击可以使用`X:Bind`
### Hyperlink
超链接
~~~
博客发在csdn ,没有授权红黑转载,没有授权推酷转载
~~~

### Repeat button
用户点击不停响应。
## Collection/data controls
### Flip view
幻灯片播放
~~~
~~~

[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"
};
~~~
~~~
~~~

## Date and time controls
### Calendar date picker
日历日期选择器


### Calendar view
日程表,让用户选择日期

### Time picker
用户选择一个时间

## Flyouts
### Flyout
显示一条消息
~~~
~~~

### Menu flyout
暂时显示命令或列出选项给用户选择
~~~
~~~
### Popup menu
弹出自己写的菜单
### Tooltip
提示
~~~
~~~
## Images
### Image
图片
~~~
~~~

如果需要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
~~~
~~~
手写

保存文件可以去edi.wang
### Shapes
椭圆,矩形、线、贝塞尔曲线路径
~~~
~~~
~~~
~~~
~~~
~~~



## Layout controls
### Border
边框
### Canvas
画板
### Grid
网格布局
### StackPanel
堆放布局
### Scroll viewer
滚动视图
~~~
~~~
### Viewbox
可以改变内容的长宽
~~~
~~~

## Media controls
### Media element
播放视频
其实我之前用它播放音频[https://github.com/lindexi/Markdown](https://github.com/lindexi/Markdown)

~~~
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
全景视图控件
~~~
~~~

## Progress controls
### Progress bar
进度条
~~~
~~~

~~~
~~~

### Progress ring
~~~
~~~

## 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)

### Password box
密码输入
~~~
~~~

### Rich edit box
~~~
~~~
### Text block
简单输出文本
~~~
~~~

### Text box
用户输入文本
~~~
~~~

博客:[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)
';