thumbnail
wpf clip 使用
下面灰色图,上面显示彩色图,彩色图上使用 Clip 切出一个圆 XAML <Border Grid.Column="0" Width="300" Height="300" Padding="0" HorizontalAlignment="Center&q…
thumbnail
wpf 倒计时 (关键帧)
XMAL <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="36" FontWeight="Bold" Foreground="RoyalBlue&q…
thumbnail
wpf 图片对比 (图片即时缩放)
使用两张图片,一张下面,一张上面 注意:图片太大的话,会变形,需要将图片缩放成 Grid 控件对应的大小 XAML <Grid x:Name="RootGrid" ShowGridLines="False" SizeChanged="FrameworkElement_OnSizeChanged…
thumbnail
wpf ListBoxItem 选中动画
XAML <Grid> <Grid.Resources> <Style x:Key="SliderStyle" TargetType="Rectangle"> <!-- 设置两端为圆角 --> <Setter Property="RadiusX&…
thumbnail
wpf 幻灯片
XAML <Grid> <!-- 将 Canvas 作为一个 200*200 的视窗,然后在里面放置 StackPanel, StackPanel 中平铺相片, --> <!-- 每次点击时,移动 StackPanel 一个相片的位置,实现图片轮播效果。 --> <!-- 有一个缺点,如果移动相片的过程中,…
thumbnail
wpf 输入框水印提示 (VisualBrush 例子)
XAML <TextBox x:Class="WpfDemoApp.TipTextBoxCtrl.TipTextBoxControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http…
thumbnail
wpf 滚动数字
设置一个竖形的数值条,使用 Border 只显示一个数值, 然后动画调动数值条的高低 XAML <Grid> <!-- 一共 10 个数值, Border 高度设置为一个数值控件的高度,然后使用动画,在这 10 个数据之间移动 --> <!-- 程序会根据高度自动适配高度 --> <Border x:Nam…
thumbnail
wpf 旋转动画
XAML 因为动画不能共用, 在后台调用代码,(Storyboard)LoadingStoryboard.Clone() 并设置一个BeginTime, 然后设置给小圆点, <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presenta…
wpf 自定义模板
+ FrameworkTemplate // 基类 + ControlTemplate // 控件模板, 会完全替代原来的模板 + DataTemplate // 数据模板 + HierarchicalDataTemplate // 树形数据模板 + ItemsPanelTemplate // ItemsControl 的 Panel 模板 控件的…
wpf 数据绑定
创建 binding 对象,并设置属性 BindingOperations.SetBinding 将 binding 对象与控件对象创建关联 代码绑定 // 创建绑定对象 var binding = new Binding { // 绑定源 Source = this.NameTextBox, // 绑定相对源, 用于绑定到同一级的另一个控件的属性…