首页 > 代码库 > WPF开发过程中遇到的小问题
WPF开发过程中遇到的小问题
1》在自定义控件时,如果想用到eventtrigger时,eventtrigger中的路由事件必须用该事件所在的类来修饰,否则访问不到该事件。例如:
?
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 | <ToggleButton x:Name= "PART_toggleButton" VerticalAlignment= "Top" IsChecked= "False" Style= "{StaticResource ToggleButtonStyle}" HorizontalAlignment= "Center" > <ToggleButton.Triggers> <EventTrigger RoutedEvent= "ToggleButton.Checked" SourceName= "PART_toggleButton" > <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName= "PART_Listbox" Storyboard.TargetProperty= "Height" Duration= "0:0:1" To= "100" FillBehavior= "HoldEnd" /> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent= "ToggleButton.Unchecked" SourceName= "PART_toggleButton" > <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName= "PART_Listbox" Storyboard.TargetProperty= "Height" Duration= "0:0:1" To= "0" FillBehavior= "HoldEnd" /> </Storyboard> </BeginStoryboard> </EventTrigger> </ToggleButton.Triggers> </ToggleButton> |
这里面如果直接写
?
1 | RoutedEvent= "Unchecked" 会把错,说找不到 |
?
1 | Unchecked路由事件。 |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。