RE: Style trigger not firing in wpf app

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Linda Liu[MSFT]

    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:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    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.


  • Linda Liu[MSFT]

    #2
    RE: Style trigger not firing in wpf app

    Hi Moondaddy,

    After doing some research, I figure the problem out.

    The main point is that the DataTrigger you use in the
    "ConnectionGrou pStyle" 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.xam l 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.xam l:

    <ResourceDictio nary
    xmlns="http://schemas.microso ft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microso ft.com/winfx/2006/xaml"
    xmlns:c="clr-namespace:Style TriggerFromPare nt">

    <Style x:Key="Connecti onGroupStyle" TargetType="{x: Type
    c:ChildControl} ">
    <Setter Property="Snaps ToDevicePixels" Value="false"/>
    <Setter Property="Visib ility" Value="Hidden"/>
    <Style.Triggers >
    <DataTrigger Value="True">
    <DataTrigger.Bi nding>
    <Binding Path="IsMouseOv er">
    <Binding.Relati veSource>
    <RelativeSour ce Mode="FindAnces tor"
    AncestorType="{ x:Type FrameworkElemen t}" AncestorLevel=" 1"/>
    </Binding.Relativ eSource>
    </Binding>
    </DataTrigger.Bin ding>
    <Setter Property="Visib ility" Value="Visible" />
    </DataTrigger>
    </Style.Triggers>
    </Style>

    </ResourceDiction ary>

    2. In the SomeControl.xam l, 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:
    msdnmg@microsof t.com.

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


    Comment

    • moondaddy

      #3
      Re: Style trigger not firing in wpf app

      Your suggestion works. Thanks!

      "Linda Liu[MSFT]" <v-lliu@online.mic rosoft.comwrote in message
      news:09aaosBtIH A.4284@TK2MSFTN GHUB02.phx.gbl. ..
      Hi Moondaddy,
      >
      After doing some research, I figure the problem out.
      >
      The main point is that the DataTrigger you use in the
      "ConnectionGrou pStyle" 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.xam l 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.xam l:
      >
      <ResourceDictio nary
      xmlns="http://schemas.microso ft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microso ft.com/winfx/2006/xaml"
      xmlns:c="clr-namespace:Style TriggerFromPare nt">
      >
      <Style x:Key="Connecti onGroupStyle" TargetType="{x: Type
      c:ChildControl} ">
      <Setter Property="Snaps ToDevicePixels" Value="false"/>
      <Setter Property="Visib ility" Value="Hidden"/>
      <Style.Triggers >
      <DataTrigger Value="True">
      <DataTrigger.Bi nding>
      <Binding Path="IsMouseOv er">
      <Binding.Relati veSource>
      <RelativeSour ce Mode="FindAnces tor"
      AncestorType="{ x:Type FrameworkElemen t}" AncestorLevel=" 1"/>
      </Binding.Relativ eSource>
      </Binding>
      </DataTrigger.Bin ding>
      <Setter Property="Visib ility" Value="Visible" />
      </DataTrigger>
      </Style.Triggers>
      </Style>
      >
      </ResourceDiction ary>
      >
      2. In the SomeControl.xam l, 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:
      msdnmg@microsof t.com.
      >
      This posting is provided "AS IS" with no warranties, and confers no
      rights.
      >
      >

      Comment

      • Linda Liu[MSFT]

        #4
        Re: Style trigger not firing in wpf app

        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:
        msdnmg@microsof t.com.

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


        Comment

        Working...