wpf日历控件制作过程分析(3)---定义DayHeaders

接上篇 http://www.cnblogs.com/Clingingboy/archive/2008/06/18/1224720.html

<!-- DayHeaders -->
                                    
< Grid  x:Name ="DayHeaders"  Grid.Column ="1" >
                                        
< Grid.ColumnDefinitions >
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                            
< ColumnDefinition />
                                        
</ Grid.ColumnDefinitions >
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="0"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=0,RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="1"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=1, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="2"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=2, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="3"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=3, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="4"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=4, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="5"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=5, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                        
< DateControls:MonthCalendarDayHeader  Grid.Column ="6"  Style =" {TemplateBinding DayHeaderStyle} "
                                    DataContext
=" {Binding Path=FirstDayOfWeek,Mode=OneWay,Converter={StaticResource MonthCalendarDayHeaderConverter},ConverterParameter=6, RelativeSource={RelativeSource AncestorType={x:Type DateControls:MonthCalendar}}} " />
                                    
</ Grid >
                                    
<!-- DayHeaders -->

FirstDayOfWeek属性类型为DayOfWeek 枚举,通过数据绑定的ConverterParameter属性传递参数,然后通过类型转换器转换数据

然后再画一条分隔线
< Rectangle  x:Name ="DayHeadersSplitLine"  Grid.Column ="1"  Fill ="Black"  Height ="1"  VerticalAlignment ="Bottom"  Margin ="2,0,2,0" />

到目前为止,默认的显示效果如下

转载于:https://www.cnblogs.com/Clingingboy/archive/2008/06/18/1224734.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值