2013-09-05 2 views
0

여러 개의 버튼이있는 창을 만들었습니다. 그 버튼들은 제가 만든 사용자 정의 컨트롤입니다.확장 버튼

이 나의 창을 내 된 UserControls 11이 포함되어 있지만 창에 추가 된 UserControls의 수는 동적이며, 지금 모습입니다 :

enter image description here

사용자가 자신의 마우스로 버튼을 가리킬 컨트롤을 20 픽셀 확장해야합니다.
문제는 컨트롤이 확장되지만 다른 컨트롤은 그대로 유지되므로 겹치게됩니다.

은 '그들이 돈 때문에 나는 아래로 확장 제어 컨트롤을 이동할 수 있습니다 어떻게 내 UserControl을

<UserControl 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
mc:Ignorable="d" 
x:Class="UserControlSolution.UserControlButton" 
x:Name="UserControl" 
Height="50"> 
<UserControl.Resources> 
    <Storyboard x:Key="OnMouseEnter1"> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="rectangle"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="1.5"/> 
     </DoubleAnimationUsingKeyFrames> 
     <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="rectangle"> 
      <EasingDoubleKeyFrame KeyTime="0" Value="12.5"/> 
     </DoubleAnimationUsingKeyFrames> 
    </Storyboard> 
</UserControl.Resources> 
<UserControl.Triggers> 
    <EventTrigger RoutedEvent="Mouse.MouseEnter"> 
     <BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}"/> 
    </EventTrigger> 
</UserControl.Triggers> 

<Grid x:Name="LayoutRoot" Height="50"> 
    <Rectangle x:Name="rectangle" RenderTransformOrigin="0.5,0.5"> 
     <Rectangle.Stroke> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#FF5C5C5C" Offset="0"/> 
       <GradientStop Color="#FF4E4E4E" Offset="1"/> 
      </LinearGradientBrush> 
     </Rectangle.Stroke> 
     <Rectangle.Fill> 
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> 
       <GradientStop Color="#FF626262" Offset="0"/> 
       <GradientStop Color="#FF3B3B3B" Offset="0.987"/> 
      </LinearGradientBrush> 
     </Rectangle.Fill> 
    </Rectangle> 
    <TextBlock x:Name="NameLabel" FontFamily="Levenim MT" FontSize="16" Foreground="#FFE5E5E5" Height="34" Width="230" Text="Onthaal Telefoon" VerticalAlignment="Top" TextAlignment="Center" HorizontalAlignment="Center" Margin="0,10,0,0"/> 
</Grid> 

이 내 창

<Window 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:UserControlSolution" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="UserControlSolution.MainWindow" 
    Title="MainWindow" Height="836" Width="262" Background="#FF2B2B2B" BorderBrush="{DynamicResource Border}" Loaded="Window_Loaded" > 

<Window.Resources> 

    <LinearGradientBrush x:Key="Border" EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0"> 
     <GradientStop Color="#FF6C6C6C" Offset="0.009"/> 
     <GradientStop Color="#FFA1A1A1" Offset="1"/> 
    </LinearGradientBrush> 

</Window.Resources> 

<StackPanel Margin="0,10,0,0"> 
    <local:UserControlButton x:Name="Robby" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Erwin" HorizontalAlignment="Center" Height="50" VerticalAlignment="Top" Width="228" Background="Black" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Laurens" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Kevin" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Liesbeth" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Jack" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Filip" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Stefaan" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Sami" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Jurgen" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
    <local:UserControlButton x:Name="Thomas" HorizontalAlignment="Center" Width="228" Background="Black" Height="50" VerticalAlignment="Top" Margin="0,0,0,10"/> 
</StackPanel> 

입니다 t overlapse? 또는 더 나은 솔루션은 무엇입니까?

+1

왜 그냥 대신'Height' 속성을 애니메이션하지 않는 다른 요소의하고 설계에 영향을 순서대로 LayoutTransform 아닌 RenderTransform을 변경해야? – Sheridan

답변

1

당신은

+0

블렌드를 사용하여이 작업을 수행했는데 RenderTransform 대신 LayoutTransform을 사용하려면 어떻게 변경해야합니까? –

관련 문제