I am working on a project and need help finding a solution for Windows 8 XAML to switch the control's visibility when you hover over another control. The control can be a button or any Windows8 control, and the code must be in XAML, because all my logic is in XAML. I have tried many XAML solutions, but I probably have something missing. In my first attempt, I wrote an event trigger, but the string cannot be converted to visibility, so the following code will work when executed.
Can anyone or any expert from Microsoft please help me with this. I really appreciate your help. I am looking for a solution that does not require code in the code, it should be the full XAML code.
<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <StackPanel Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> <Button Margin="5" x:Name="btn1">Button 1</Button> <Button Margin="5" x:Name="btn2"> <Button.Triggers> <EventTrigger RoutedEvent="Button.GotFocus"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="btn1" Storyboard.TargetProperty="Button.Visibility" To="Collapsed" Duration="0:0:1"/> </Storyboard> </BeginStoryboard> </EventTrigger> <EventTrigger RoutedEvent="Button.LostFocus"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="btn1" Storyboard.TargetProperty="Button.Visibility" To="Visible" Duration="0:0:1"/> </Storyboard> </BeginStoryboard> </EventTrigger> </Button.Triggers> Button 2 </Button> <Button Margin="5" x:Name="btn3">Button 3</Button> </StackPanel> </Page>
source share