随笔分类 -  WPF

1
摘要:1、e.source:逻辑树中事件的原始元2、e.originalsource:视觉树中事件的原始元素 阅读全文
posted @ 2013-03-21 13:48 麦芽糖! 阅读(644) 评论(0) 推荐(0)
摘要:<i:Interaction.Triggers> <i:EventTrigger EventName="SelectionChanged"> <cmd:EventToCommand Command="{Binding ValudChangedCommand}"/> </i:EventTrigger> </i:Interaction.Triggers> 阅读全文
posted @ 2013-03-08 13:12 麦芽糖! 阅读(197) 评论(0) 推荐(0)
摘要:<Window.Resources> <Style x:Key="PathStyle" TargetType="Path"> <Setter Property="Fill" Value="#FF0092FF"></Setter> <Setter Property="Stretch" Value="Fill... 阅读全文
posted @ 2013-02-18 17:17 麦芽糖! 阅读(227) 评论(0) 推荐(0)
摘要:private T FindVisualChild<T>(DependencyObject obj) where T : DependencyObject { for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { DependencyObject child = VisualTreeHelper.GetChild(obj, i); if (child != null && child is T) ... 阅读全文
posted @ 2012-12-25 15:56 麦芽糖! 阅读(186) 评论(0) 推荐(0)
摘要:<Window.Resources> <x:ArrayExtension x:Key="test" Type="sys:String"> <sys:String>a1</sys:String> <sys:String>a2</sys:String> <sys:String>a3</sys:String> </x:ArrayExtension> </Window.Resources> <Grid> <ComboBox H 阅读全文
posted @ 2012-10-18 10:52 麦芽糖! 阅读(325) 评论(0) 推荐(0)
摘要:结局方案截图:CustomToggleButton.xaml代码:<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Local="clr-namespace:CustomControls"> <Style TargetType="{x:Type Local:Custo 阅读全文
posted @ 2012-09-14 14:25 麦芽糖!
摘要:先看显示效果:(图1)代码A请留意上面加粗及红色文字部分。WPF提供两个类来描述路径数据:一个是StreamGeometry,另一个是PathFigureCollection。类似:<Path Stroke="Black" Data="M 100,240 C 510,300 80,100 300,160 H40 v80" />的形式是StreamGeometry的XAML代码表示形式,也是最简洁的表示形式。而类似: 1 <Path Stroke="Black" StrokeThickness="1" 阅读全文
posted @ 2012-09-12 16:11 麦芽糖! 阅读(326) 评论(0) 推荐(0)
摘要:控件背景:有多个button需要有背景图片,但是wpf自带的button并没有imagebutton,如何要实现button的背景图片,需要重写template,但是如果有N个button,那需要些N个button的template,很麻烦。所以,就有自定控件的button产生<Grid Margin="50"> <Grid.RowDefinitions> <RowDefinition Height="auto" /> <RowDefinition Height="auto" /> &l 阅读全文
posted @ 2012-08-07 14:52 麦芽糖! 阅读(328) 评论(1) 推荐(0)
摘要:XPath语法:http://www.w3school.com.cn/xpath/xpath_syntax.aspXML<Cities> <City> <CityName>北京</CityName> </City> <City> <CityName>上海</CityName> </City> <City> <CityName>广州</CityName> </City></Cities>XAML<Window.Resourc 阅读全文
posted @ 2012-08-02 11:09 麦芽糖! 阅读(1017) 评论(0) 推荐(0)
摘要:<ComboBox Grid.Row="1"> <ComboBox.Resources> <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">0</sys:Double> </ComboBox.Resources> </ComboBox> 阅读全文
posted @ 2012-08-01 14:18 麦芽糖! 阅读(713) 评论(0) 推荐(0)
摘要:1.sys的程序集:xmlns:sys="clr-namespace:System;assembly=mscorlib" ListBox的数据呈现可以用:<sys:String></sys:String>或<ListBoxItem Content="" />的形式进程呈现<ListBox> <ListBoxItem Content="ListBoxItem Method" /> <sys:String>sys:a</sys:String> <sy 阅读全文
posted @ 2012-08-01 13:39 麦芽糖! 阅读(327) 评论(0) 推荐(0)
摘要:1.UserControl能比较快速的打造自定义控件,但其对模板样式等缺乏很好的支持,打造出来的控件不如WPF内置控件一样灵活2.为了让你打造的控件更标准化,更灵活以及更具有普遍意义,你需要用到的CustomControl一, 不一定需要自定义控件在使用WPF以前,动辄使用自定义控件几乎成了惯性思维,比如需要一个带图片的按钮,但在WPF中此类任务却不需要如此大费周章,因为控件可以嵌套使用以及可以为控件外观打造一套新的样式就可以了.是否需要我们来自定义控件,这需要你考虑目前已有控件的真正逻辑功能而不要局限于外观,如果目前的控件都不能直觉地表达你的想法,那么你可以自己来打造一个控件,否则,也许我们 阅读全文
posted @ 2012-08-01 11:27 麦芽糖! 阅读(2416) 评论(0) 推荐(0)
摘要:public partial class SecondPage : Window { public SecondPage() { InitializeComponent(); this.Loaded += this.SecondPage_Loaded; } private void SecondPage_Loaded(object sender, RoutedEventArgs e) { CustomColorsList colorsList = new... 阅读全文
posted @ 2012-07-25 17:11 麦芽糖! 阅读(427) 评论(0) 推荐(0)
摘要:<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Paragraph FontSize="18">Flow Format Example</Paragraph> <Paragraph> Lorem ipsum dolor sit amet, consectetuer 阅读全文
posted @ 2012-07-25 08:58 麦芽糖! 阅读(464) 评论(0) 推荐(0)
摘要:<TextBlock> <TextBlock.Triggers> <EventTrigger RoutedEvent="Loaded"> <BeginStoryboard> <Storyboard> <ColorAnimation Storyboard.TargetName="color" Storyboard.Targe... 阅读全文
posted @ 2012-07-20 15:26 麦芽糖! 阅读(371) 评论(0) 推荐(0)
摘要:<Grid Name="grdRoot"> <Button Name="btnClick" Content="Click" Width="72" Height="24" /> <!--LinearGradientBrush只需要注意几个属性: 1.SpreadMethod:指用什么样的方式去处理不在线性渐变中的区域(即扩展方式,用个比喻吧, 把下面浅绿色的比作一张桌面背景图,把整个区域比作桌面,SpreadMethod 指定的就是【 平铺 / 拉伸】 2.Mappi 阅读全文
posted @ 2012-07-19 16:29 麦芽糖! 阅读(273) 评论(0) 推荐(1)
摘要:<Window.Resources> <Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Grid> <Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" BorderTh... 阅读全文
posted @ 2012-07-19 11:14 麦芽糖! 阅读(823) 评论(0) 推荐(1)
摘要:一:xaml版<TextBlock Height="23" HorizontalAlignment="Left" Cursor="Hand" Margin="10,10,0,0" Name="tbClick" Text="Click To Show" VerticalAlignment="Top" /> <ListView Name="lvRoot" Width="200" Height=" 阅读全文
posted @ 2012-07-17 09:38 麦芽糖! 阅读(233) 评论(0) 推荐(0)
摘要:<Window x:Class="WpfApp_Delete.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" xmlns:Custom="clr-namesp 阅读全文
posted @ 2012-07-09 13:49 麦芽糖! 阅读(169) 评论(0) 推荐(0)
摘要:OneWay 源更新时,目标也更新TwoWay 源更新时目标也更新,或者目标更新时同时更新源OneTime 仅当应用程序启动时或DataContext进行更改时更新目标属性。绑一次就不更维护更新,目标相当于源的一次性镜像OneWayToSource 目标更新时更新源,和OneWay相反大部分WPF自带的控件的dependency property默认的是OneWay,像TextBox.Text默认的是TwoWay。值得注意的事,只读属性只能设置成OneWay,不能是TwoWay,否则运行时异常。对于 OneWay 或 TwoWay 绑定,对源的动态更改不会自动传播到目标。必须在源对象上实现IN 阅读全文
posted @ 2012-07-09 10:35 麦芽糖! 阅读(324) 评论(0) 推荐(1)

1