Apologies but I am new to WPF. I am using VS 2010. I am trying to set the visible property of my button to Visible when the mouse moves over the button but the visibility property does not work.
The example below has three buttons:
1. One which sets the text to Red
2. The button should become visible but does not
3. The button should become not visible but starts to flicker.
Can someone please tell me why the visible property does not work correctly on the last two buttons?
This is part of a project where there will be two buttons on a user control that will be added to a Datagrid and allow users to add or delete a comment. (Similar to the delete of a tab in Visual Studio) Does anyone know of an example like this?
<usercontrol x:class="HideButtons.UserControl1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="97" d:DesignWidth="122">
<grid height="76" width="92">
<Button Content="Add" Height="23" HorizontalAlignment="Left" Name="Add"
VerticalAlignment="Top" Width="75">
<Button.Style>
<Style TargetType="{x:Type Button}">
<setter property="Visibility" value="Visible">
<Style.Triggers>
<trigger property="IsMouseOver" value="True"> <setter property="Control.Foreground" value="#FFF61C1C">
<setter property="Control.FontWeight" value="Bold">
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button Content="Delete" Height="23" HorizontalAlignment="Left" Margin="0,23,0,0" Name="Delete"
VerticalAlignment="Top" Width="75">
<Button.Style>
<Style TargetType="{x:Type Button}">
<setter property="Visibility" value="Hidden">
<Style.Triggers>
<trigger property="IsMouseOver" value="True"> <setter property="Visibility" value="Visible">
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button Content="Test" Height="23" HorizontalAlignment="Left" Margin="0,46,0,0" Name="Test"
VerticalAlignment="Top" Width="75">
<Button.Style>
<Style TargetType="{x:Type Button}">
<setter property="Visibility" value="Visible">
<Style.Triggers>
<trigger property="IsMouseOver" value="True"> <setter property="Visibility" value="Hidden">
</Style.Triggers>
</Style>
</Button.Style>
</Button>