随笔分类 - WPF
1
摘要:cs代码:/// /// MainWindow.xaml 的交互逻辑 /// public partial class MainWindow : Window { public MainWindow() { Initial...
阅读全文
摘要:var l =newLabel(){Content="Hello"};l.Measure(newSize(double.PositiveInfinity,double.PositiveInfinity));Size s = l.DesiredSize;
阅读全文
摘要:codeusing System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.W...
阅读全文
摘要:public void MouseWheelEventHandler(object sender, MouseWheelEventArgs e) { double oldScalX = ((ScaleTransform)canvas.RenderT...
阅读全文
摘要:正常定义的以来属性,在XAML里设置值得时候是不触发Setter的,只能在code中用。监听PropertyChangedCallback事件可以感知XAML里的设置,这样才能code和XAML配合使用。http://stackoverflow.com/questions/5644081/wpf-usercontrol-dependency-property-setter-not-triggeringhttp://msdn.microsoft.com/zh-cn/library/vstudio/ms745025.aspxhttp://msdn.microsoft.com/zh-cn/libra
阅读全文
摘要:转自:http://www.cnblogs.com/gnielee/archive/2010/10/04/windows7-extend-aero-glass.html Windows 7 操作系统默认具有一款玻璃效果主题(Aero Glass)。如果选择了该款主题,所有的应用程序标题栏都会处于玻璃透明效果(如下图)。这个功能是由Desktop Window Manager(DWM)服务支持的。 默认情况下,我们编写的应用程序在Windows 7 中也只有标题栏和窗口框架会具备玻璃效果,其他区域仍是不透明状态(如下图)。如果想将程序整体都改为上图IE 窗口的效果,可以使用DWM API 将玻.
阅读全文
摘要:http://files.cnblogs.com/wangjixianyun/TaskWindow.zip
阅读全文
摘要:转自:http://www.cnblogs.com/atskyline/archive/2012/09/20/2694878.html第一步 引入到Winows API偷懒直接写在类里 1: [DllImport("user32.dll")] 2: public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk); 3: [DllImport("user32.dll")] 4: public static extern bool Unregis
阅读全文
摘要:viewbox会自动缩放里面的组件,如果里面的组件已有确定的大小,就会均匀的缩放。<Window x:Class="WpfTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="768" Width="1920
阅读全文
摘要:绑定元素的大小一般会想到Width和Height但是wpf里的Width和Height如果没有显示的设置过大小那么得到的就是NaN要动态得到元素的大小要用ActualWidth、ActualHeight<UserControl x:Class="园区展示程序.MyRichTextBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" .
阅读全文
摘要:在wpf和C#中Environment.TickCount可以用来获得系统开机到现在的毫秒数
阅读全文
摘要:Mouse.GetPosition(window);可以在任何时间获得相对任意元素的鼠标位置Mouse.Capture(el);可以让某个元素获得所有的鼠标事件不管他应不应该的到鼠标事件Mouse.Capture(null);解除
阅读全文
摘要:this.image.Source = new BitmapImage(new Uri(imgSource, UriKind.Absolute)); this.imgSource = imgSource;
阅读全文
摘要:组件放在ViewBox里,在大小变化的时候字体大小会自动缩放,测试Button放到ViewBox里是这样的。
阅读全文
摘要:Window.GetWindow(【Visual】) 静态方法可以获得任意组件的顶层窗口。
阅读全文
摘要:window = Window.GetWindow(【Visual】);Point offset = 【Visual】.TransformToAncestor(window).Transform(new Point(0, 0))上面代码可以获得任意组件的窗口坐标。获取鼠标相对于任意组件的位置用Mouse.GetPosition(IInputElement relativeTo)或MouseEventArgs.GetPosition(IInputElement relativeTo)获取屏幕鼠标位置用win32apiusing System;using System.Collections.Ge
阅读全文
摘要: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.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using Syste...
阅读全文
摘要:在获取wpf自定义组件的宽度和高度的时候,如果直接在InitializeComponent();后面用this.Width,和this.ActualWidth会得到Nan和0,因为组件还没有被计算大小。要获得组件的宽度和高度可以添加Loaded事件的响应函数,在事件函数里面在用this.Width就可以得到组件的宽度。public lineNet(){ InitializeComponent(); Loaded += delegate { Line line11 = new Line(); Line line12 = new Line(); ...
阅读全文
1

浙公网安备 33010602011771号