来自row0的菜单't show correctly

Simsen.vejle.

活跃的成员
加入
2月14日,2021年
消息
31
编程经验
Beginner
在顶部我有一个菜单。单击一个按钮时,我想要显示展开2行的StackPanel。但它只显示了一些下拉菜单 - 其余部分隐藏在Row1后面(在这种情况下,TextBlock但是它将是一个UserControl)。所以它只显示了一些堆叠的按钮。我该怎么办,在StackPanel上显示所有按钮?我试图制作一个Rowspan 2.我试图在2个网格中单独分开。但没有任何帮助。

如果你想让我寄给你解决方案就这样说。

此致
Simsen. :)

mainwindow.xaml.xaml.

C#:
<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf" x:Name="AnsiBug"  x:Class="AnsiBug.MainWindow"
        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"
        xmlns:local="clr-namespace:AnsiBug"
        mc:Ignorable="d"
        Title="MainWindow" Height="800" Width="1200" HorizontalAlignment="Center" VerticalAlignment="Center" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <!--Base Button Style-->
    </Window.Resources>
    <StackPanel>
        <Grid Margin="5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="150"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="130" />
                <RowDefinition Height="600" />
            </Grid.RowDefinitions>
                <Image Source="/Images/Logo/ANSI.gif" Grid.Row="0" Grid.Column="0" Height="100" />
                <Image Source="/Images/Logo/logoBug.gif" Grid.Row="0" Grid.Column="2" Height="100" />
                
                <Grid Grid.Column="1">
                    <Grid Margin="5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="*" />                           
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="180" />
                        </Grid.RowDefinitions>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="0" Margin="5 0 0 0">
                            <Button x:Name="BtnProjects" Content="Projekter" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                            <StackPanel x:Name="ProjectsSubMenu">
                                <Button x:Name="BtnDashBoard" Content=" Dashboard" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnNewBug" Content=" Ny fejl" Style="{StaticResource TopSubMenuButton}" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1" Margin="5 0 0 0">
                            <Button x:Name="BtnLists" Content="Lister" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                            <StackPanel x:Name="ListsSubMenu">
                                <Button x:Name="BtnMyBugs" Content=" Mine fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnNewBugs" Content=" Nye fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnAllBugs" Content=" Alle fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnUnAssignedBugs" Content=" Ikke tildelte fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnClosedBugs" Content=" Lukkede fejl" Style="{StaticResource TopSubMenuButton}" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="2" Margin="5 0 0 0">
                            <Button x:Name="BtnPreferences" Content="Indstillinger" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                            <StackPanel x:Name="PreferencesSubMenu">
                                <Button x:Name="BtnMyInfo" Content=" Min info" Style="{StaticResource TopSubMenuButton}" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="3" Margin="5 0 0 0">
                            <Button x:Name="BtnAdministration" Content="Administration" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                            <StackPanel x:Name="AdministrationSubMenu">
                                <Button x:Name="BtnShowUsers" Content=" Vis brugere" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnAddUser" Content=" Tilføj bruger" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnEditAccount" Content=" Ret konto" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnShowProjects" Content=" Vis projekter" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnAddProject" Content=" Tilføj projekt" Style="{StaticResource TopSubMenuButton}" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="4" Margin="5 0 0 0">
                            <Button x:Name="BtnReports" Click="BtnReports_Click" Content="Rapporter" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                            <StackPanel x:Name="ReportsSubMenu" Grid.RowSpan="2">
                                <Button x:Name="BtnTextReports" Content=" Tekst rapporter" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnReporsMyBugs" Content=" Mine fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnReporsNewBugs" Content=" Nye fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnReporsAllBugs" Content=" Alle fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnReporsClosedBugs" Content=" Lukkede fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnReporsNoAssignedBugs" Content=" Ikke tildelte fejl" Style="{StaticResource TopSubMenuButton}" />
                                <Button x:Name="BtnManagement" Content=" Management" Style="{StaticResource TopSubMenuButton}" />
                            </StackPanel>
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="5" Margin="5 0 0 0">
                            <Button x:Name="BtnLogout" Click="BtnLogout_Click" HorizontalAlignment="Right" HorizontalContentAlignment="Right" Content="Log ud" Style="{StaticResource TopMenuButton}" />
                            <Image Source="/Images/TopDivider.jpg" />
                        </StackPanel>
                    </Grid>
                </Grid>

            <WrapPanel Orientation="Vertical" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" >
                <TextBlock x:Name="TextTextBlock" TextWrapping="Wrap" Text="Her kommer anden række sol sommer strand og vand en kvinde og en mand. Glemmer du så husker jeg det ord for ord alting brast men det gør ikke spor minderne har jeg da lov at have dem kan du aldrig nej aldrig tag Husker du de ord vi sammen fandt" />
            </WrapPanel>
        </Grid>
        
        <!--<Grid Margin="15 5 15 5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1150" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="600" />
            </Grid.RowDefinitions>
            <TextBlock Text="Her kommer anden række sol sommer strand og vand en kvinde og en mand. Glemmer du så husker jeg det ord for ord alting brast men det gør ikke spor minderne har jeg da lov at have dem kan du aldrig nej aldrig tag Husker du de ord vi sammen fandt" />
        </Grid>-->
    </StackPanel>
</Window>

mainwindows.xaml.cs.

C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace AnsiBug
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            HideSubPanels();           
        }

        public void HideSubPanels()
        {
            ProjectsSubMenu.Visibility = Visibility.Collapsed;           
            ListsSubMenu.Visibility = Visibility.Collapsed;
            PreferencesSubMenu.Visibility = Visibility.Collapsed;
            AdministrationSubMenu.Visibility = Visibility.Collapsed;
            ReportsSubMenu.Visibility = Visibility.Collapsed;
        }

        private void BtnLogout_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void BtnReports_Click(object sender, RoutedEventArgs e)
        {
            HideSubPanels();
            ReportsSubMenu.Visibility = Visibility.Visible;
        }
    }
}

和findmy app.xaml.

C#:
<Application x:Class="AnsiBug.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:AnsiBug"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <!--#region Buttons -->       
        <!--Almindelige knapper-->
        <Style TargetType="Button">
            <Setter Property="Background" Value="#005b7f"/>
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="Margin" Value="3" />
            <Setter Property="Padding" Value="5 5 5 5" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          TextElement.Foreground="{TemplateBinding Foreground}"></ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#005b7f" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>
        
        <!--Top Menu knapper-->
        <Style TargetType="Button" x:Key="TopMenuButton">
            <Setter Property="Background" Value="White"/>
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="12" />           
            <Setter Property="Width" Value="120" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Padding" Value="5 0 2 2" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          TextElement.Foreground="{TemplateBinding Foreground}"></ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="White" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>

        <!--Top SubMenu knapper-->
        <Style TargetType="Button" x:Key="TopSubMenuButton">
            <Setter Property="Background" Value="#005b7f"/>
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Verdana" />
            <Setter Property="FontSize" Value="12" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Width" Value="122" />
            <Setter Property="HorizontalContentAlignment" Value="Left" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="Transparent" />
            <Setter Property="Height" Value="30" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                            <ContentPresenter x:Name="PART_Content"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          TextElement.Foreground="{TemplateBinding Foreground}"></ContentPresenter>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="#005b7f" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <!--#endregion-->
    </Application.Resources>
</Application>
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,854
地点
切萨皮克,va.
编程经验
10+
有没有原因是您使用内置的WPF菜单并只是重新键入它?你为什么要尝试这样做像基于网络的方法到建造菜单一样?
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,854
地点
切萨皮克,va.
编程经验
10+
If you really must insist on your current approach, consider using the Popup element which should let you break out of the bounds of the grid cell.
 
解决方案

Simsen.vejle.

活跃的成员
加入
2月14日,2021年
消息
31
编程经验
Beginner
If you really must insist on your current approach, consider using the Popup element which should let you break out of the bounds of the grid cell.
非常感谢你 :) 我想我在谷歌上发现了一些东西在弹出窗口上找到了一些东西。我会尝试一下。

最良好的问候
Simsen. :)
 

跳伞运动员

工作人员
加入
2019年4月6日
消息
2,854
地点
切萨皮克,va.
编程经验
10+
这两个人可能值得阅读......

使用Windows演示基础(WPF),您可以使用自己可重用的模板自定义现有的控件的视觉结构和行为。模板可以全局应用于应用程序,Windows和Pages,或直接控制。 如果需要为现有控件创建新模板,可以涵盖要求您创建新控件的大多数情况。


 

Simsen.vejle.

活跃的成员
加入
2月14日,2021年
消息
31
编程经验
Beginner
最佳 底部