首页 > 其他 > 详细

WPF开发过程中遇到的小问题

时间:2014-05-26 03:09:22      阅读:325      评论:0      收藏:0      [点我收藏+]

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路由事件。

WPF开发过程中遇到的小问题,布布扣,bubuko.com

WPF开发过程中遇到的小问题

原文:http://www.cnblogs.com/my-sky/p/3749271.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!