我是WPF
的新手,可能很簡單。我不明白爲什麼BorderBrush
不顯示刪除Button
。默認情況下,Button
不可見,但在鼠標移過Button
時顯示。當鼠標結束Button
時,底層TextBlock
顯示爲應該顯示,但不顯示Border
。邊框不顯示在按鈕上
有沒有人有關於我如何查看按鈕的建議Border
。
以下是我XAML
:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="150" Width="325">
<Window.Resources>
<Storyboard x:Key="MakeToolbarVisible">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0.5"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="MakeToobarHidden">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Style x:Key="Toolbar">
<Style.Triggers>
<Trigger Property="UIElement.IsMouseOver" Value="True">
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource MakeToobarHidden}"/>
</Trigger.ExitActions>
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource MakeToolbarVisible}"/>
</Trigger.EnterActions>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Border>
<Grid Margin="0">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="30" />
</Grid.ColumnDefinitions>
<TextBlock Text="enter some text here!" Margin="8,19.058,8,0" VerticalAlignment="Top" Foreground="#B43C1C26" HorizontalAlignment="Right"/>
<TextBox TextWrapping="WrapWithOverflow" Margin="8,19.058,0,2.463" FontSize="11" AcceptsReturn="True" AcceptsTab="True" Visibility="Visible" BorderThickness="0" Background="{x:Null}"/>
<WrapPanel Grid.Row="1" Margin="8,8,8,8">
<TextBlock Text="29.8.1995" Foreground="#B43C1C26" FontSize="10" />
</WrapPanel>
<StackPanel Grid.Column="1" Margin="5,5,5,8" Grid.RowSpan="2" Opacity="0" Style="{StaticResource Toolbar}">
<Button x:Name="Remove" BorderBrush="DarkRed" BorderThickness="1" Cursor="Hand">
<Button.Template>
<ControlTemplate>
<TextBlock Text="r" FontFamily="Marlett" FontSize="12"/>
</ControlTemplate>
</Button.Template>
</Button>
</StackPanel>
</Grid>
</Border>
</Grid>
謝謝,我學到新的東西。您的解決方案按預期工作 – user2254699 2013-04-08 14:19:57