471,337 Members | 845 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

RE: Style trigger not firing in wpf app

Hi Moondaddy,

This is a quick note to let you know that I'm performing research on this
issue and will get back to you ASAP.

I appreciate your patience!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #1
3 3446
Hi Moondaddy,

After doing some research, I figure the problem out.

The main point is that the DataTrigger you use in the
"ConnectionGroupStyle" is not correct. You should use the relative source
mode of FindAncestor to get notified when the IsMouseOver property of the
parent element of the ChildControl changes.

In addition, in the SomeControl.xaml file, you shouldn't set the Visibility
property explicitly because it will override the style that is applied to
the element. You should set the initial value of the Visibility property in
the style.

The modifications are as follows.

1. In the Dictionary1.xaml:

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:StyleTriggerFromParent">

<Style x:Key="ConnectionGroupStyle" TargetType="{x:Type
c:ChildControl}">
<Setter Property="SnapsToDevicePixels" Value="false"/>
<Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
<Binding Path="IsMouseOver">
<Binding.RelativeSource>
<RelativeSource Mode="FindAncestor"
AncestorType="{x:Type FrameworkElement}" AncestorLevel="1"/>
</Binding.RelativeSource>
</Binding>
</DataTrigger.Binding>
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>

</ResourceDictionary>

2. In the SomeControl.xaml, remove the Visibility property from the
ChildControl element.

Please try my suggestion and let me know the result.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #2
Your suggestion works. Thanks!

"Linda Liu[MSFT]" <v-****@online.microsoft.comwrote in message
news:09**************@TK2MSFTNGHUB02.phx.gbl...
Hi Moondaddy,

After doing some research, I figure the problem out.

The main point is that the DataTrigger you use in the
"ConnectionGroupStyle" is not correct. You should use the relative source
mode of FindAncestor to get notified when the IsMouseOver property of the
parent element of the ChildControl changes.

In addition, in the SomeControl.xaml file, you shouldn't set the
Visibility
property explicitly because it will override the style that is applied to
the element. You should set the initial value of the Visibility property
in
the style.

The modifications are as follows.

1. In the Dictionary1.xaml:

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:StyleTriggerFromParent">

<Style x:Key="ConnectionGroupStyle" TargetType="{x:Type
c:ChildControl}">
<Setter Property="SnapsToDevicePixels" Value="false"/>
<Setter Property="Visibility" Value="Hidden"/>
<Style.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
<Binding Path="IsMouseOver">
<Binding.RelativeSource>
<RelativeSource Mode="FindAncestor"
AncestorType="{x:Type FrameworkElement}" AncestorLevel="1"/>
</Binding.RelativeSource>
</Binding>
</DataTrigger.Binding>
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>

</ResourceDictionary>

2. In the SomeControl.xaml, remove the Visibility property from the
ChildControl element.

Please try my suggestion and let me know the result.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #3
Hi Moondaddy,

Thank you for your confirmation. I'm glad to hear that the problem is
solved now.

If you have any other questions in the future, please don't hesitate to
contact us. It's always our pleasure to be of assistance!

Have a nice weekend!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Martin | last post: by
7 posts views Thread by yoyo | last post: by
2 posts views Thread by Net Virtual Mailing Lists | last post: by
1 post views Thread by aj70000 | last post: by
1 post views Thread by julie | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.