Quantcast
Channel: VBForums - WPF, WCF, WF
Viewing all articles
Browse latest Browse all 256

First time with style triggers

$
0
0
Ok - so I wanted to change the cursor to a HAND if you hover over a textblock that has a tooltip that is not null.

From what I've read on the interweb condition's can only be done on EQUAL. NOT EQUAL is not an option.

After struggling with this I came up with a workaround - although it seems a bit of a hack.

Code:

            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Cursor" Value="Hand" />
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsMouseOver" Value="True"/>
                        <Condition Property="Control.ToolTip" Value="{x:Null}"/>
                    </MultiTrigger.Conditions>
                    <MultiTrigger.Setters>
                        <Setter Property="Cursor" Value="Arrow" />
                    </MultiTrigger.Setters>
                </MultiTrigger>
            </Style.Triggers>

The above XAML changes the CURSOR to a HAND on IsMouseOver - and then the MultiTrigger.Condition changes is BACK to an ARROW if the ToolTip is null.

This actually works - which surprised me. I thought it would error out with conflicting triggers.

Any other way to do this? Is this actually acceptable?

Viewing all articles
Browse latest Browse all 256

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>