2012-11-03 5 views
0

MouseOver 안에있는 StackPanel을 사용하여 테두리의 BorderColor를 변경하는 방법을 알고 싶습니다. TargetName을 StackPanel의 VSM 안에있는 경계의 이름으로 설정해 보았습니다. 내가 해제 방법입니다 알지만, 오히려 뭔가를하려고 ...컨트롤 주위에 테두리 색 변경

<Border x:Name="LinksBorder" > 
<StackPanel x:Name="LinksStackPanel" Margin="10" Orientation="Horizontal" FlowDirection="RightToLeft" HorizontalAlignment="Center" Width="311"> 
    <VisualStateManager.VisualStateGroups> 
     <VisualStateGroup x:Name="CommonStates"> 
      <VisualState x:Name="Normal"> 
      </VisualState> 
      <VisualState x:Name="MouseOver"> 
      <Storyboard> 
       <ColorAnimation 
       Duration="0" Storyboard.TargetName="LinksBorder" Storyboard.TargetProperty="(BorderBrush).(SolidBrush)" To="#FF0000" /> 
      </Storyboard> 
      </VisualState> 
     </VisualStateGroup> 
     </VisualStateManager.VisualStateGroups> 

답변

0

내 해결 방법 :

아직
Private Sub LinksStackPanel_MouseEnter(sender As Object, e As System.Windows.Input.MouseEventArgs) Handles LinksStackPanel.MouseEnter 
    LinksBorder.BorderBrush = New Media.SolidColorBrush(Colors.Red) 
End Sub 

Private Sub LinksStackPanel_MouseLeave(sender As Object, e As System.Windows.Input.MouseEventArgs) Handles LinksStackPanel.MouseLeave 
    LinksBorder.BorderBrush = ColorFromHex("#FF00FF2A") 
End Sub 

Private Function ColorFromHex(hex As String) As Brush 
    hex = hex.Replace("#", String.Empty) 
    Dim a = (Convert.ToUInt32(hex.Substring(0, 2), 16)) 
    Dim r = (Convert.ToUInt32(hex.Substring(2, 2), 16)) 
    Dim g = (Convert.ToUInt32(hex.Substring(4, 2), 16)) 
    Dim b = (Convert.ToUInt32(hex.Substring(6, 2), 16)) 
    Return New SolidColorBrush(Color.FromArgb(CByte(a), CByte(r), CByte(g), CByte(b))) 
End Function 

것은 ... 너무 다른 방법을보고 싶어