Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Can trigger work outside a style ?

 
 
Old 03-15-2006   #1 (permalink)
Philippe Lavoie


 
 

Can trigger work outside a style ?

I'm really confused, I have a Stack Panel

Inside it there is a StackPanel.Triggers section

which is declared as

<StackPanel.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked"
SourceName="ResizeButton">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ExpandCart}"
x:Name="ExpandCart_BeginStoryboard"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked"
SourceName="ResizeButton">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource ShrinkCart}"
x:Name="ShrinkCart_BeginStoryboard"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Checked"
SourceName="InStorePickupButton">
<EventTrigger.Actions>
<Setter Property="Visibility" Value="Visible"
TargetName="InStorePickupOptions"/>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Checked"
SourceName="ShipToButton">
<EventTrigger.Actions>
<Setter Property="Visibility" Value="Visible"
TargetName="ShipToOptions"/>
</EventTrigger.Actions>
</EventTrigger>

</StackPanel.Triggers>

The above fails miserably since .NET decides that Visibility can't be
set because it's a DependentProperty.

However, the following in the same page works

<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="Action" />
<Setter Property="Foreground" Value="#ffffffff"/>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter Property="Visibility" Value="Collapsed"
TargetName="Action" />
</Trigger>
</ControlTemplate.Triggers>


The difference is that one acts on the ControlTemplate of one of the
control and the other works on the whole page. Why can't I apply the
same kind of behavior that I use on a control template inside a page?

Please help

Phil

My System SpecsSystem Spec
Old 03-15-2006   #2 (permalink)
Marcus


 
 

Re: Can trigger work outside a style ?

The first thing I can see that might be wrong about this is that
"Trigger" class uses a collection os "SetterBase" and "EventTrigger"
use a collection of "TriggerAction" as their content properties...

This mean that normally, "Setter" is not a valid item for the
"EventTrigger" class.

You could try to place a trigger onto a DP in your custom StackPanel
declaration that would perform the same function as your "Checked" or
"Unchecked"...

Marcus

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
DllImport doesn't work in ASP.NET for old C-style dlls .NET General
Font Size - XP style vs Vista style Vista General
Font Size - XP style vs Vista style Vista General
Windows API to trigger schedule tasks does not work for Vista Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46