03 2011 档案

摘要:转载在: http://www.cnblogs.com/zhouyinhui/archive/2007/03/28/690993.hstring GetTemplateXamlCode(Control ctrl) { FrameworkTemplate template = ctrl.Template; string xaml = ""; if (template != null) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentCh 阅读全文
posted @ 2011-03-31 10:49 xiaokang088 阅读(228) 评论(0) 推荐(0) 编辑
摘要:When use ListView, i want to find it's child :scrollViewer.use code as bellow:svALlItems = (ScrollViewer)(VisualTreeHelper.GetChild(lvAllItems, 0) as Border).Child;when change theme from areo to non-aero ,for example as classic theme, application crash,the reason at above statement.Use VisualTre 阅读全文
posted @ 2011-03-30 11:59 xiaokang088 阅读(318) 评论(0) 推荐(0) 编辑
摘要:Stream GetImageFromControl(Control control) { MemoryStream ms = null; DrawingVisual drawingVisual = new DrawingVisual(); using (DrawingContext context = drawingVisual.RenderOpen()) { VisualBrush brush = new VisualBrush(gd) { Stretch = Stretch.None }; context.DrawRectangle(brush, null, new Rect(0, 0. 阅读全文
posted @ 2011-03-29 16:03 xiaokang088 阅读(10984) 评论(4) 推荐(3) 编辑
摘要:mutex可以 用来控制应用程序只启动一次,但是要注意mutex不能被回收,否则就无法发挥作用了。例如: bool ret; using (System.Threading.Mutex mutex = new System.Threading.Mutex(true, "WpfMuerterrrterterttex", out ret)) { if (!ret) Environment.Exit(0); }这样子写,mutex会被回收,如下的方法是正确的:using System;using System.Windows;namespace WpfApplication1{ 阅读全文
posted @ 2011-03-29 13:32 xiaokang088 阅读(3655) 评论(1) 推荐(1) 编辑
摘要:WPF中摄像头的读取。http://social.msdn.microsoft.com/Forums/zh-CN/wpfzhchs/thread/ed555e11-20f1-4b7c-b590-430e72369ad1WPF MediaKit - For webcam, DVD and custom video support in WPFWebcam control with WPF or how to create high framerate player with DirectShow by using InteropBitmap in WPF application 阅读全文
posted @ 2011-03-25 11:48 xiaokang088 阅读(2307) 评论(0) 推荐(0) 编辑
摘要:用过小屏幕的朋友可能会碰到这个问题,例如,wpf窗体宽度为1000,显示器屏幕宽度只有800,打开wpf应用程序后,剩余的200没了,移动窗体发现这200根本就没有render出来。解决办法,设置MinWidth = 1000,窗口就会全部显示。如果要考虑mui,SizeToContent = true,最小宽度就没办法设定了,怎么办呢?重写measureOverride ,自己测量尺寸,然后在loaded中加入this.MinWidth = this.ActualWidth;大功告成。 阅读全文
posted @ 2011-03-24 13:10 xiaokang088 阅读(497) 评论(0) 推荐(0) 编辑
摘要:之前见到VC用DebugView 调试程序,非常羡慕,琢磨之后发现wpf也可以用这个东东。程序里面写Trace.WriteLine("Trace的东东"),Relase 后,运行DebugView,执行相应的操作,即可 看到 输出的信息 .又发现,可以通过设置配置文件实现 输出到txt文件。App.config 如下<?xml version="1.0" encoding="utf-8" ?><configuration><system.diagnostics> <trace autoflus 阅读全文
posted @ 2011-03-24 10:17 xiaokang088 阅读(2297) 评论(1) 推荐(0) 编辑
摘要:XAML 中使用了 <ListView Height="144" HorizontalAlignment="Left" Margin="144,62,0,0" Name="lvAllItems" VerticalAlignment="Top" Width="161" />cs中查找listview的scrollviewer:ScrollViewer sv = (ScrollViewer)(VisualTreeHelper.GetChild(lvAllItems, 阅读全文
posted @ 2011-03-23 17:27 xiaokang088 阅读(382) 评论(0) 推荐(0) 编辑
摘要:最近处理了一个关于DPI的问题,想想挺有意思的,拿出来分享一下。先搞清楚一下几个概念:DPI:dots per inch ,每英寸的点数。我们常说的鼠标DPI,是指鼠标移动一英寸的距离滑过的点数;打印DPI,每英寸的长度打印的点数;扫描DPI,每英寸扫描了多少个点。(更多请参考百度百科http://baike.baidu.com/view/49853.htm)像素:pixel,picute和element的缩写。像素可以简单的理解为DPI里面的点。例如,显示器的分辨率为1024像素*768像素,就是说显示器的横向可显示1024个点(像素),纵向科研可以显示768个点(像素)。有的显示器每个显示 阅读全文
posted @ 2011-03-02 20:37 xiaokang088 阅读(6767) 评论(2) 推荐(1) 编辑