我需要做什么:
在活动 <?xml version="1.0" encoding="utf-8"?>
<db xmlns:site="http://www.google.com">
<params>
<param name="parser_version" value="2"/>
<param name="data_type" value="Events"/>
<param name="created" value="2017-11-15T12:21:18"/>
<param name="program_version" value="4.5.20.1092"/>
</params>
<tables>
<table name="Events">
<fields>
<field name="UniqueID" type="Integer"/>
<field name="ID" type="AutoInc"/>
<field name="Date" type="Date"/>
<field name="Time" type="Time"/>
<field name="Code" type="Integer"/>
<field name="UserID" type="Integer"/>
<field name="UserGUID" type="String"/>
<field name="ReaderID" type="Integer"/>
<field name="Type" type="Integer"/>
<field name="Modified" type="Boolean"/>
<field name="ModifReason" type="String"/>
</fields>
<rows>
<row>
<f>3086647</f>
<f>18091842</f>
<f>2017-11-14</f>
<f>21:32:10</f>
<f>1</f>
<f>202</f>
<f>{ED53D55D-4B99-41F3-95BD-6945A989155C}</f>
<f>803</f>
<f>32</f>
<f>null</f>
<f>null</f>
</row>
...
</rows>
</table>
</tables>
时,没有 GotFocus
和 MouseEnter
< / strong> run。
事件 MouseLeave
后, LostFocus
和 MouseEnter
再次生效
鉴于需求,我已编写以下代码,但 MouseLeave
和 Pause
的命令不起作用。
Resume
答案 0 :(得分:1)
您可以使用一个简单的EventTrigger
来使用Trigger
来代替使用MultiTrigger
,这可以让您定义一个复杂的条件。
我有一个解决方案。
首先,将元素的默认Opacity
设置为0,因为这将是正确的初始状态:
<Image Opacity="0"/>
<Image Opacity="0" />
<TextBox Opacity="0" />
然后,定义将完成工作的触发器:
<ControlTemplate.Triggers>
<!-- This trigger will unconditionally show the elements,
if the text box has keyboard focus,
and hide them, if the text box is not focused -->
<Trigger Property="IsKeyboardFocusWithin" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Show}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource Hide}"/>
</Trigger.ExitActions>
</Trigger>
<!-- This trigger will partly show the elements, if the mouse cursor
is over the text box, but it is not focused. If it's focused, then
the previous trigger has already done its job -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsKeyboardFocusWithin" Value="False"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ShowHalf}" x:Name="ShowHalfStoryboard" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="ShowHalfStoryboard"/>
</MultiTrigger.ExitActions>
</MultiTrigger>
<!-- This trigger will hide the elements, if the mouse cursor
is outside the text box, and it is not focused. If it's focused, then
the first trigger has already done its job. If it's not focused and
the cursor is over the text box, then the previous trigger works. -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="False" />
<Condition Property="IsKeyboardFocusWithin" Value="False"/>
</MultiTrigger.Conditions>
<MultiTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Hide}" x:Name="HideStoryboard" />
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<RemoveStoryboard BeginStoryboardName="HideStoryboard"/>
</MultiTrigger.ExitActions>
</MultiTrigger>
</ControlTemplate.Triggers>