码迷,mamicode.com
首页 > 其他好文 > 详细

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

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

标签:style   class   blog   c   code   tar   

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开发过程中遇到的小问题

标签:style   class   blog   c   code   tar   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!