随笔分类 - WPF
摘要:第一步 在自定义控件里加上声明 /// <summary> /// The click event /// </summary> public static readonly RoutedEvent userControlClickEvent = EventManager.RegisterRoute
阅读全文
摘要:1、按钮控件的前台 <UserControl x:Class="JapanSubway.UserControls.LeftMenuButton" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="ht
阅读全文
摘要:可以给控件增加模版样式 如下就把一个按钮,完成变成了其它的样式: <Window.Resources> <ControlTemplate x:Key="myTemplate" TargetType="Button"> <Border Background="Red" CornerRadius="5"
阅读全文
摘要:样式可以像css那样,把属性写到公共的地方,然后各个需要用到的控件再去引用 1、最简单的样式Demo 下面是定义一个最简单的样式,然后让2个按钮去引用: <Window.Resources> <Style x:Key="buttonStyle" TargetType="Button"> <Sette
阅读全文
摘要:主要有5种: 1、StackPanel 这种布局是按照子控件的顺序逐个按顺序排队显示,可以设置排队的方式 下面的代码是水平排队展示: <StackPanel Orientation="Horizontal"> <Button Width="100" Height="20" Content="test
阅读全文
摘要:1、建立一个新的类库并写一个类:ImageButton,代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using Sy
阅读全文
摘要:<TextBlock Cursor="Hand" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,0" Name="btnMin" Text="{Binding RowData.Row.TypeIcon.Ic
阅读全文
摘要:第一步:在Window.Resources里定义右键菜单 <Window.Resources> <ContextMenu x:Key="ContextMenu"> <MenuItem Name="NewFile" Header="新建文件夹"/> <Separator></Separator> <M
阅读全文
摘要:Window.GetWindow(this).Close();
阅读全文
摘要:第一步:建立一个模版文件,如下: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/200
阅读全文