0

その中にあるStackPanelの上にMouseOverを使用してBorderの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>
4

1 に答える 1

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

まだ他の方法も見たいです...

于 2012-11-04T00:50:42.250 に答える