我有一个控制模板,我想只有当鼠标超过它的某个部分时才会触发一些动作。这是我的模板的核心(为演示而简化):
<ControlTemplate TargetType="{x:Type graphicElements:MyTabItem}">
<Grid x:Name="templateRoot">
<Grid x:Name="templateChild" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=templateChild}" Value="True">
<Setter Property="Background" TargetName="templateRoot" Value="Red" />
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
当我将ElementName作为templateRoot时,它会工作并变为红色。当我把它作为templateChild时,它不起作用......为什么不呢?
答案 0 :(得分:3)
在代码的简化版中,与templateRoot网格的绑定也不起作用。问题是,WPF需要对元素执行Hit Tests以引发某些事件或更新IsMouseOver属性。由于您没有为网格设置背景画笔,因此它们永远不会接收鼠标输入,因此您的触发器将永远不会执行。试试这个:
select Date, User, min(Time) as start_time, max(time) as end_time,
Location,
listagg(Service, ',') within group (order by service),
count(*) as cnt
from (select t.*,
row_number() over (date order by time) as seqnum,
row_number() over (partition by user, date, location order by time) as seqnum_2
from t
) t
group by Date, User, Location, (seqnum - seqnum_2);