摘要: http://msdn.microsoft.com/zh-cn/library/ms597484.aspx #region text public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } //public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", // typeof(string), 阅读全文
posted @ 2011-04-21 16:44 xiaokang088 阅读(809) 评论(0) 推荐(0) 编辑
摘要: 先上个示例 <ItemsControl Margin="10" ItemsSource="{Binding}" Name="itemsControl"><ItemsControl.Template> <ControlTemplate TargetType="{x:Type ItemsControl}"> <Border CornerRadius="5"> <ScrollViewer VerticalScrollBarVisibility=&q 阅读全文
posted @ 2011-04-15 09:16 xiaokang088 阅读(8573) 评论(7) 推荐(3) 编辑
摘要: add textblockon ui , as bellow:<Grid><TextBlock Height="23" HorizontalAlignment="Left" Margin="16,18,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" /></Grid>add style for textBlock <Window.Resources> 阅读全文
posted @ 2011-04-11 10:57 xiaokang088 阅读(304) 评论(0) 推荐(0) 编辑
摘要: C# 调用C++的dll,通过DllImport方式。以下例子包含以下几种参数传递方式:传递string、Int、Int数组、结构体、结构体数组。比较懒,没写注释,呵呵,各位辛苦了。demo在这里C++ Dll 如下:// dllmain.cpp : Defines the entry point for the DLL application.#include "stdafx.h"#include <stdio.h>#include <tchar.h>BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_ 阅读全文
posted @ 2011-04-08 16:54 xiaokang088 阅读(25545) 评论(9) 推荐(4) 编辑
摘要: 重现步骤:1.写一个很简单的wpf程序,UI上有一个checkbox,运行起来。2.在桌面点击右键菜单--》Screen Resolution --》orientation 更改为 portrait,点击apply,然后Keep changes。试一试touch到 checkbox上面,会不会有效果。3.如果仍然可用,重复第二步,把orientation 改为landscape,点击apply,然后Keep changes。反复更改这个属性,在两个值之间切换。大约2次以后,会发现touch到checkbox上以后,checkbox不会被选中或者取消选中,也就是失效了。然后寻寻觅觅,发现点击其他 阅读全文
posted @ 2011-04-06 19:46 xiaokang088 阅读(519) 评论(1) 推荐(0) 编辑
摘要: 最近纠结于wpf 多国语言处理的问题,先说说找到的以下几种方案。1.借用vc的处理方式,编译完了以后每个语言产生一个dll,分别放在语言文件夹里面,Wpf 使用dllImport调用win32 api中的loadstring方法提取MUI资源,然后赋值为ui。微软自己去判断该用哪个语言,不用自己操心。优点:可靠,毕竟那么多地方都这么干的。缺点:麻烦了点2. 微软给出的解决方案,地址如下:http://msdn.microsoft.com/zh-cn/library/ms788718.aspx其中里面有一句,让我很失望:用 XAML 编写 UI;避免在代码中创建 UI。当您使用 XAML 创建 阅读全文
posted @ 2011-04-02 10:23 xiaokang088 阅读(2724) 评论(18) 推荐(2) 编辑
摘要: 转载在: 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 阅读(10973) 评论(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 阅读(3653) 评论(1) 推荐(1) 编辑