Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用按钮wpf.net创建导航栏_.net_Wpf_Xaml_Navbar - Fatal编程技术网

使用按钮wpf.net创建导航栏

使用按钮wpf.net创建导航栏,.net,wpf,xaml,navbar,.net,Wpf,Xaml,Navbar,我想创建一个导航栏,类似于在wpf中创建网站时使用的导航栏。我想要这样的东西: 我在xaml中有以下代码: <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <Colu

我想创建一个导航栏,类似于在wpf中创建网站时使用的导航栏。我想要这样的东西:

我在xaml中有以下代码:

<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0" Grid.Column="0" Content="Companies" />
        <Button Grid.Row="0" Grid.Column="1" Content="Orders" />
        <Button Grid.Row="0" Grid.Column="2" Content="Employes" />
        <Button Grid.Row="0" Grid.Column="3" Content="Timesheets" />
        <Button Grid.Row="0" Grid.Column="4" Content="Payroll" />
        <Button Grid.Row="0" Grid.Column="5" Content="Billing" />
        <Button Grid.Row="0" Grid.Column="6" Content="Reports" />
    </Grid>
这是我的布局:

我怎么做这个导航栏?有可能创造出这样的奇迹吗?如果是,我怎么做?
谢谢

这应该可以,但这不是按钮样式问题,也没有箭头位

Private Sub Load() Handles Me.Loaded
    MenuReset()
End Sub
Private Sub MenuReset() Handles menu1.MouseLeave, menu2.MouseLeave, menu3.MouseLeave
    Dim fore, back, border As New SolidColorBrush
    fore.Color = Color.FromRgb(0, 0, 0)
    back.Color = Color.FromArgb(0, 0, 0, 0)
    border.Color = Color.FromArgb(0, 0, 0, 0)
    menu1.Foreground = fore
    menu1.Background = back
    menu1.BorderBrush = border
    menu2.Foreground = fore
    menu2.Background = back
    menu2.BorderBrush = border
    menu3.Foreground = fore
    menu3.Background = back
    menu3.BorderBrush = border
End Sub
Private Sub MenuMouseMove(sender As Label, e As EventArgs) Handles menu1.MouseMove, menu2.MouseMove, menu3.MouseMove
    Dim grad As New LinearGradientBrush
    Dim fore, border As New SolidColorBrush
    grad.StartPoint = New Point(0.5, 0)
    grad.EndPoint = New Point(0.5, 1)
    grad.GradientStops.Add(New GradientStop(Color.FromRgb(146, 179, 19), 0))
    grad.GradientStops.Add(New GradientStop(Color.FromRgb(116, 158, 9), 1))
    fore.Color = Color.FromRgb(255, 255, 255)
    border.Color = Color.FromArgb(255, 0, 0, 0)
    sender.Background = grad
    sender.Foreground = fore
    sender.BorderBrush = border
End Sub

<Grid Background="#ff86878a">
    <Grid x:Name="Menu" Margin="0" VerticalAlignment="Top" Height="30">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="auto"/>
            <ColumnDefinition Width="auto"/>
        </Grid.ColumnDefinitions>
        <Grid.Background>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFC4C4C4" Offset="0.873"/>
                <GradientStop Color="#FFDEDEDE"/>
                <GradientStop Color="#FF9C9C9C" Offset="0.92"/>
                <GradientStop Color="#FF626466" Offset="0.96"/>
            </LinearGradientBrush>
        </Grid.Background>
        <Label x:Name="menu1" Grid.Column="0" Content="File" HorizontalAlignment="Left" Margin="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="20,0,20,0" BorderBrush="Black" BorderThickness="0,0,0,3">
            <Label.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF92B312" Offset="0"/>
                    <GradientStop Color="#FF749E09" Offset="1"/>
                </LinearGradientBrush>
            </Label.Background>
        </Label>
        <Label x:Name="menu2" Grid.Column="1" Content="Gates" HorizontalAlignment="Left" Margin="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="20,0,20,0" BorderBrush="Black" BorderThickness="0,0,0,3">
            <Label.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF92B312" Offset="0"/>
                    <GradientStop Color="#FF749E09" Offset="1"/>
                </LinearGradientBrush>
            </Label.Background>
        </Label>
        <Label x:Name="menu3" Grid.Column="2" Content="Flip Flops" HorizontalAlignment="Left" Margin="0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Padding="20,0,20,0" BorderBrush="Black" BorderThickness="0,0,0,3">
            <Label.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF92B312" Offset="0"/>
                    <GradientStop Color="#FF749E09" Offset="1"/>
                </LinearGradientBrush>
            </Label.Background>
        </Label>
    </Grid>

</Grid>

我想你需要一个TabControl和。努力吧。当你有特殊问题的时候来这里。你的问题太宽泛了。我用的C是一样的吗?XAML是一样的,但是用C你需要先调用变量类型,然后输入变量名。。。例如:作为对象的发送方的对象发送方