简介
此样式基于bootstrap-3.3.0,样式文件里的源码行数都是指的这个版本.CSS源文件放到了Content文件夹下的bootstrap.css
WPF样式和CSS还是不太相同,所以有些内容实现上稍有出入,有些内容用法不太一样,有些内容并没有实现
但至少,一些概念,尺寸和取色,还是很好的借鉴
博客说明按Bootstrap官方文档的顺序来写
App.xaml里引用Bootstrap.xaml资源
<application.resources><resourcedictionary><resourcedictionary.mergeddictionaries><resourcedictionary></resourcedictionary></resourcedictionary.mergeddictionaries></resourcedictionary></application.resources>
排版
标题
效果

代码
<label></label> <label></label> <label></label> <label></label> <label></label> <label></label>
副标题
效果

代码
<stackpanel><label></label> <label></label> </stackpanel><stackpanel><label></label> <label></label> </stackpanel><stackpanel><label></label> <label></label> </stackpanel><stackpanel><label></label> <label></label> </stackpanel><stackpanel><label></label> <label></label> </stackpanel><stackpanel><label></label> <label></label> </stackpanel>
代码
内联代码
效果

代码
<stackpanel><label></label>
<label>" Style="{DynamicResource code}"></label>
<label></label>
</stackpanel>
用户输入
效果

代码
<stackpanel><label></label> <label></label> </stackpanel>
代码块
效果

代码
<label>代码块: Foreground:#333 Background:#f5f5f5 BorderBrush:#ccc</label>
辅助文本
效果

代码
表格
代码
<datagrid><datagrid.columns><datagridtextcolumn></datagridtextcolumn><datagridtextcolumn></datagridtextcolumn><datagridtextcolumn></datagridtextcolumn></datagrid.columns></datagrid>
表单
WPF没有表单的概念,所以说明就不按官方文档的顺序了
文本输入框
效果

密码框
效果

代码
<passwordbox></passwordbox><passwordbox></passwordbox><passwordbox></passwordbox><passwordbox></passwordbox><passwordbox></passwordbox><passwordbox></passwordbox><passwordbox></passwordbox>
效果

代码
<checkbox></checkbox><checkbox></checkbox><checkbox></checkbox><checkbox></checkbox>
单选框
效果

代码
<radiobutton></radiobutton><radiobutton></radiobutton><radiobutton></radiobutton><radiobutton></radiobutton>
下拉框
效果

代码
<combobox><comboboxitem>苹果</comboboxitem><comboboxitem>橡胶</comboboxitem><comboboxitem>桔子</comboboxitem></combobox><combobox><comboboxitem>苹果</comboboxitem><comboboxitem>橡胶</comboboxitem><comboboxitem>桔子</comboboxitem></combobox><combobox><comboboxitem>苹果</comboboxitem><comboboxitem>橡胶</comboboxitem><comboboxitem>桔子</comboboxitem></combobox>
按钮
代码
<button></button> <button></button> <button></button> <button></button> <button></button> <button></button>
切换按钮
效果

代码
<togglebutton></togglebutton><togglebutton></togglebutton><togglebutton></togglebutton><togglebutton></togglebutton><togglebutton></togglebutton><togglebutton></togglebutton>
辅助类
Contextual colors
效果

代码
Contextual backgrounds
效果

代码
<label></label> <label></label> <label></label> <label></label> <label></label>
输入框组
插件
效果

代码
<textbox></textbox><textbox></textbox>
作为额外元素的按钮
效果

代码
xmal代码:
<textbox></textbox><textbox><textbox.tag><path></path></textbox.tag></textbox>
后台代码C#:
private void InputGroupButton_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(((TextBox)sender).Text);
}
进度条
效果

代码
<progressbar></progressbar><progressbar></progressbar><progressbar></progressbar><progressbar></progressbar><progressbar></progressbar>
面板
基本实例
效果

代码
<contentcontrol><contentcontrol></contentcontrol></contentcontrol>
带标题的面版
效果

代码
<contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol>
带脚注的面版
效果

代码
<contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol>
情境效果
效果

代码
<contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol><contentcontrol.content><grid><grid.columndefinitions><columndefinition></columndefinition><columndefinition></columndefinition></grid.columndefinitions><grid.rowdefinitions><rowdefinition></rowdefinition><rowdefinition></rowdefinition></grid.rowdefinitions><label></label> <textbox></textbox><label></label> <textbox></textbox></grid></contentcontrol.content></contentcontrol></stackpanel></contentcontrol><contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol><contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol><contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol><contentcontrol><stackpanel><contentcontrol></contentcontrol><contentcontrol></contentcontrol></stackpanel></contentcontrol>
更多Bootstrap风格的WPF样式相关文章请关注PHP中文网!










