WP7备注(40)(TemplatePart)
2011-05-10 12:20 血糯米Otomii 阅读(453) 评论(0) 编辑 收藏 举报TemplatePart的作用是*.cs中对于*.xaml中定义的控件进行获取,并进行操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [TemplateVisualStateAttribute(Name = "Normal" , GroupName = "CommonStates" )] [TemplateVisualStateAttribute(Name = "MouseOver" , GroupName = "CommonStates" )] [TemplateVisualStateAttribute(Name = "Disabled" , GroupName = "CommonStates" )] [TemplateVisualStateAttribute(Name = "Focused" , GroupName = "FocusStates" )] [TemplateVisualStateAttribute(Name = "Unfocused" , GroupName = "FocusStates" )] [TemplatePartAttribute(Name = "HorizontalTemplate" , Type = typeof (FrameworkElement))] [TemplatePartAttribute(Name = "HorizontalTrackLargeChangeDecreaseRepeatButton" , Type = typeof (RepeatButton))] [TemplatePartAttribute(Name = "HorizontalTrackLargeChangeIncreaseRepeatButton" , Type = typeof (RepeatButton))] [TemplatePartAttribute(Name = "HorizontalThumb" , Type = typeof (Thumb))] [TemplatePartAttribute(Name = "VerticalTemplate" , Type = typeof (FrameworkElement))] [TemplatePartAttribute(Name = "VerticalTrackLargeChangeDecreaseRepeatButton" , Type = typeof (RepeatButton))] [TemplatePartAttribute(Name = "VerticalTrackLargeChangeIncreaseRepeatButton" , Type = typeof (RepeatButton))] [TemplatePartAttribute(Name = "VerticalThumb" , Type = typeof (Thumb))] public class Slider : RangeBase |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <phone:PhoneApplicationPage.Resources> <ControlTemplate x:Key= "bareBonesSliderTemplate" TargetType= "Slider" > <Grid> <Grid Name= "HorizontalTemplate" > <Grid.ColumnDefinitions> <ColumnDefinition Width= "Auto" /> <ColumnDefinition Width= "Auto" /> <ColumnDefinition Width= "*" /> </Grid.ColumnDefinitions> <RepeatButton Name= "HorizontalTrackLargeChangeDecreaseRepeatButton" Grid.Column= "0" Content= "-" /> <Thumb Name= "HorizontalThumb" Grid.Column= "1" /> <RepeatButton Name= "HorizontalTrackLargeChangeIncreaseRepeatButton" Grid.Column= "2" Content= "+" /> </Grid> <Grid Name= "VerticalTemplate" > <Grid.RowDefinitions> <RowDefinition Height= "*" /> <RowDefinition Height= "Auto" /> <RowDefinition Height= "Auto" /> </Grid.RowDefinitions> <RepeatButton Name= "VerticalTrackLargeChangeDecreaseRepeatButton" Grid.Row= "0" Content= "-" /> <Thumb Name= "VerticalThumb" Grid.Row= "1" /> <RepeatButton Name= "VerticalTrackLargeChangeIncreaseRepeatButton" Grid.Row= "2" Content= "+" /> </Grid> </Grid> </ControlTemplate> </phone:PhoneApplicationPage.Resources> |
1 2 3 4 5 | public override void OnApplyTemplate() { base .OnApplyTemplate(); //获取TemplateApart控件 } |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
· 现代计算机视觉入门之:什么是视频
· 你所不知道的 C/C++ 宏知识
· 不到万不得已,千万不要去外包
· C# WebAPI 插件热插拔(持续更新中)
· 会议真的有必要吗?我们产品开发9年了,但从来没开过会
· 【译】我们最喜欢的2024年的 Visual Studio 新功能
· 如何打造一个高并发系统?