WPF
会飞的尼古拉斯
没有个性,但比较尿性
展开
-
关于wpf中binding如何给converter传递控件
<Popup x:Name="dispatchPop" PlacementTarget="{Binding ElementName=griddatalist}" StaysOpen="True" IsOpen="False" Width="{Binding ElementName=griddatalist, Path=ActualWidth, Conv原创 2021-12-16 14:19:25 · 718 阅读 · 0 评论 -
wpf 中在style中使用multibinding 设置Grid.Column
<Image Height=" 8" Width="17" x:Name="FXImage" Margin="5" Source="{Binding stationDirection,ConverterParameter=0,Converter={StaticResource a07}}" HorizontalAlignment="Center" VerticalAlignment="Center"> <Image.Style> ...原创 2021-12-03 13:15:40 · 998 阅读 · 0 评论 -
wpf在style的资源文件中使用Converter
形如下,将converter的类库引用进来<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxe="http://schemas.devexpress.com/winfx/200原创 2021-11-12 10:18:34 · 668 阅读 · 0 评论 -
WPF 启动exe时传递参数
1 新建一个类,包含main函数我写在APP.Xaml.cs里using System;using System.Collections.Generic;using System.Configuration;using System.Data;using System.Linq;using System.Threading.Tasks;using System.Windows;namespace HLZDVideo{ /// <summary> /// Ap原创 2021-11-08 13:36:06 · 899 阅读 · 0 评论 -
wpf 接收Windows消息 WndProc
using System;using System.Collections.Generic;using System.Linq;using System.Runtime.InteropServices;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.D原创 2021-11-06 01:38:38 · 644 阅读 · 0 评论 -
wpf 递归查找某个控件的特定父窗体
public static T FindParent<T>(DependencyObject child) where T : DependencyObject{ //get parent item DependencyObject parentObject = VisualTreeHelper.GetParent(child); //we've reached the end of the tree if (parentObject == null) ret原创 2021-10-21 13:21:42 · 305 阅读 · 0 评论 -
wpf 通过代码获取鼠标滚轮
有些时候我们需要在一个控件里获取鼠标滚轮事件构造函数注册事件this.PreviewMouseWheel += new System.Windows.Input.MouseWheelEventHandler(this.Kk_MouseWheel);事件实现private void Kk_MouseWheel(object sender, MouseWheelEventArgs e) { int delta = e.Delta;原创 2021-10-08 09:24:48 · 658 阅读 · 0 评论 -
WPF 移动鼠标到指定位置
private void SetPosition(int a, int b){ SetCursorPos(a, b);}[DllImport("User32.dll")]private static extern bool SetCursorPos(int X, int Y);原创 2021-09-23 10:16:05 · 693 阅读 · 0 评论 -
wpf 设置无边框的透明button
一定要重写Template <!--地图定位按钮的样式--> <Style TargetType="Button" x:Key="maplocation"> <Setter Property="BorderThickness" Value="0"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="T原创 2021-09-15 17:01:57 · 1617 阅读 · 0 评论 -
wpf 忽略listbox的选中效果
添加如下style即可 <ListBox.ItemContainerStyle> <Style TargetType="ListBoxItem"> <Setter Property="IsSelected" Value="{Binding Content.IsSelected, Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>原创 2021-09-15 16:38:58 · 1030 阅读 · 0 评论 -
wpf解决获取ActualHeight为0
ActualHeight 在构造函数获取为0 是正常的,因为此时control还没有显示出来处理方式为在构造函数添加this.SizeChanged += OnWindowSizeChanged;OnWindowSizeChanged 里处理你得逻辑即可protected void OnWindowSizeChanged(object sender, SizeChangedEventArgs e) { List<string> lines = C原创 2021-09-08 16:48:20 · 1119 阅读 · 0 评论 -
wpf 遍历listbox的Item
<StackPanel> <ListBox Width="400" Height="300" x:Name="describeString" ItemTemplate="{DynamicResource ListBoxTemplate}" /> </StackPanel> <DataTemplate x原创 2021-08-10 14:45:23 · 1100 阅读 · 0 评论 -
C# 按enter键,实现移动到下个tabindex(焦点)
重写窗体的KeyDown事件即可protected override void OnKeyDown(KeyEventArgs e) { if (e.Key == Key.Enter) { // MoveFocus takes a TraveralReqest as its argument. TraversalRequest request = new TraversalRequ原创 2021-06-15 16:21:21 · 786 阅读 · 0 评论 -
wpf 使用templatebinding,并设置button的背景图片
https://www.cnblogs.com/xpvincent/p/4475679.htmlxaml<Window x:Class="WpfButton.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http:/原创 2021-08-09 10:11:05 · 1049 阅读 · 0 评论 -
wpf TextBlock MultiBunding 设置前景颜色
public class BusNameColor : IMultiValueConverter { //正向转换 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { DateTime plan = System.Convert.ToDateTime(values[0]);...原创 2021-07-12 12:39:15 · 201 阅读 · 0 评论 -
C# wpf 自定义路由事件
Main.xaml<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008".原创 2021-07-06 11:20:21 · 308 阅读 · 0 评论 -
wpf 使用代码获取样式并设置
style.xaml<Style x:Key="chkBase" TargetType="CheckBox"> <Setter Property="IsChecked" Value="False"/> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="#999"/&g转载 2021-06-28 15:40:40 · 630 阅读 · 0 评论 -
wpf 获取itemcontrol里的按钮
比如想要获取以下xaml里的按钮<ItemsControl BorderBrush="Black" BorderThickness="2" Name="cat1" ItemsSource="{Binding Questions[0]}" Margin="65,0,0,165"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> &l原创 2021-06-28 10:56:25 · 1087 阅读 · 0 评论 -
wpf datagrid 给表头添加右键,以及实现datagrid的数据筛选
ColumnHelper是给列头添加右键,动态设置列显示using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Controls.Primitives;using System.Wi.原创 2021-06-25 13:05:23 · 1653 阅读 · 1 评论 -
wpf lookupedit 的使用
xaml<Window x:Class="WpfApp1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"原创 2021-06-23 13:44:19 · 359 阅读 · 0 评论 -
WPF DockLayoutManager 使用,支持拖拽
https://docs.devexpress.com/WPF/6820/controls-and-libraries/layout-management/dock-windows/getting-started/dock-layout-manager需要安装devexpress并添加引用APP.xaml<Application x:Class="WpfApp2.App" xmlns="http://schemas.microsoft.com/winfx/2006原创 2021-06-17 14:42:53 · 639 阅读 · 0 评论 -
wpf Popup使用
看名字就知道,它是一个弹出控件,顾名思义,我们可以用它来实现类似Combobox那种,点击后弹出下面选项列表的操作。MainWindow.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.W原创 2021-06-09 09:29:42 · 802 阅读 · 0 评论 -
WPF datagrid添加右键,实现列的动态展示
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Xml;namespace WpfApp1.Helper{ public cla原创 2021-06-08 14:17:13 · 1291 阅读 · 1 评论 -
wpf multivalueconverter
实际应用中除了根据单个value绑定进行数据转换外,也存在根据多个值进行数据绑定,以listview为例xaml<UserControl x:Class="HLZD.SMS.UI.WPF.Projects.GrapDispatching.CcMultiChangePlan" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schem原创 2021-06-08 08:58:16 · 395 阅读 · 0 评论 -
wpf trigger demo
本文设计简单的trigger,datatrigger以及multitriggertrigger是指我们设定的属性的值与期望的一致,则触发multitrigger包含conditions集合,指所有条件都满足才触发Styles/Dictionarys.xaml存储样式<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="原创 2021-05-31 16:55:59 · 88 阅读 · 0 评论 -
wpf 设置listbox数据模板
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"原创 2021-05-31 09:31:04 · 1066 阅读 · 0 评论 -
wpf自定义命令
封装ICommand子类using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Input;namespace WpfApplication.Bases{ public class RelayCommand : ICommand { public..原创 2021-05-28 16:23:03 · 360 阅读 · 0 评论 -
wpf 中数据验证
https://www.cnblogs.com/3xiaolonglong/p/9777063.htmlcode behind形式<Window x:Class="WpfApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"原创 2021-05-28 13:53:09 · 276 阅读 · 0 评论 -
wpf 中如何引用自定义控件
Ellis.yaml<UserControl x:Class="WpfApplication.UserControlItems.Ellis" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://sch.原创 2021-05-27 14:01:38 · 1652 阅读 · 0 评论 -
C# WPF 设置按钮样式无边框
<Window x:Class="WpfApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xml原创 2021-05-18 14:08:08 · 1087 阅读 · 0 评论 -
C# WPF 设置treeview
结构RelayCommandusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Input;namespace WpfApp{ public class RelayCommand : ICommand { public event EventHa原创 2021-05-14 15:18:26 · 636 阅读 · 1 评论 -
C#递归,绑定treeview
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace WpfApp.Model{ public class DepartmentModel { public List<DepartmentModel> Nodes { get; set; } pub.原创 2021-05-11 17:01:40 · 544 阅读 · 0 评论 -
WPF 命令绑定,以及设置Combobox的数据源
Student.csusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;namespace WpfDependencyApp.Model{ public class Student:DependencyObject { public static.原创 2021-05-11 09:27:45 · 1217 阅读 · 0 评论 -
wpf中的convert的使用
需求中经常有这样的问题,我输入的是一种数据类型,但是我在界面显示的完全不同的东西。这样就需要转换。比如界面的listbox绑定的数据源为Student类,需要将性别显示出来Studentusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace WpfApp.Model{ public class .原创 2021-05-08 09:27:10 · 1433 阅读 · 0 评论 -
wpf 另存style在统一的文件中,并在需要时引用
1 新建一个xaml 文件保存style<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApp.Styles"> &原创 2021-04-27 09:58:07 · 194 阅读 · 0 评论 -
wpf 将style放在一个资源中,以供全局使用
新建一个.xaml的资源文件在该文件中编写样式代码:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib"> <Style原创 2020-11-09 12:44:25 · 2124 阅读 · 0 评论 -
wpf datagrid分组
<Window x:Class="WpfApplication7.MainWindow" xmlns="<a class="vglnk" href="http://schemas.microsoft.com/winfx/2006/xaml/presentation" rel="nofollow"><span>http</span><s...原创 2019-11-05 12:09:28 · 1336 阅读 · 0 评论 -
Prism框架搭建(MVVM)
一.新建一个项目,把App.xaml 中的启动路径删掉,在App.saml.cs中重写OnStartup方法.启动初始化文件Bootstrapper.cs二.1/在项目中创建Bootstrapper.cs初始化文件,继承MefBootstrapper类,重写ConfigureAggregateCatalog()方法设定参数(使用范围).导入Mef Prism5.0版本的包.2/...原创 2019-06-04 13:44:20 · 3062 阅读 · 0 评论 -
wpf Demo URL
UI 控件: Telerik WPFi. Demo: https://demos.telerik.com/wpf/ii. Sample: http://demos.telerik.com/xaml‐sdkbrowser/原创 2019-06-03 12:01:03 · 297 阅读 · 0 评论 -
WPF国际化语言设置
添加resources文件文件名以resources.zh-cn.resx这种形式命名加载不同的resx文件演示通过注册表读取程序应该加载的resx文件regisKey regis = new regisKey();regis.RegistFileName = “lang”; if (!regis.IsRegeditItemExist()) { ...原创 2019-05-16 14:18:40 · 688 阅读 · 0 评论