摘要:有个需求需要禁用StackPanel,结果发现StackPanel没有IsEnable属性。再试了一下,Canvas和Grid也都没有IsEnable。目前找到的解决方法是把StackPanel包裹在一个ContentControl中,如下 <ContentControl IsEnabled="False"> <StackPanel> <!--some code--> </StackPanel> </ContentControl>
阅读全文
摘要:终于受够了VS默认的颜色配置,昨天放狗一搜,发现了一个好地方,http://studiostyl.es/喜欢哪个颜色,直接下载导入到VS中就可以了。导入方式:Tools\Import and Export Settings我使用了里面排名第一的配置Son of Obsidian并做了一点修改,现在代码看起来是这个样子:看起来很舒服吧 :)附配置文件下载: 点我点我
阅读全文
摘要:控件绑定 <Grid x:Name="LayoutRoot"> <StackPanel> <ScrollBar x:Name="bar" Orientation="Horizontal" Height="20" /> <TextBox x:Name="tb" Text="{Binding ElementName=bar, Path=Value, Mode=OneWay, UpdateSourceTrigger=Default}" /&
阅读全文
摘要:这里是指定义在XMAL中的Resources,而非项目中的资源(Assembly Resource)。XAML中定义资源的方法: <StackPanel> <StackPanel.Resources> <ResourceDictionary> <SolidColorBrush x:Key="brushBlue" Color="Yellow" /> </ResourceDictionary> </StackPanel.Resources> ...
阅读全文
摘要:这两天看到Dependency Property,这东西比以前Winform中的Property(CLR Property, 看到别人这么叫)强大多了。以前项目中为了设置字体,缓 存了所有的空间并挨个设置,现在有了Dependency Property,只要设置窗体的字体,所有子控件都会继承窗体的设置。 在layout的配合下,还可以方便实现窗体及控件自适应字体的大小。 首先是一个WPF的例子,改造自《WPF程序设计指南》第8章。我改的好无聊 -_-Button控件,改变Text属性时会自动在后面加上“_Eric” public class EricButton : Button ...
阅读全文
摘要:有这么一段代码,主要用于数据验证, 来自http://www.cnblogs.com/webabcd/archive/2009/08/10/1542663.html#2446195<sdk:Label Target="{Binding ElementName=salary}"/><TextBox x:Name="salary" Width="100" Text="{Binding Salary, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnEx
阅读全文