Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.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
C# 按钮不能完全点击_C#_Wpf_Xaml_Button - Fatal编程技术网

C# 按钮不能完全点击

C# 按钮不能完全点击,c#,wpf,xaml,button,C#,Wpf,Xaml,Button,我只是编程了一个没有窗口边框的自己的窗口。所以我的退出按钮只是右上角的一个按钮。此按钮不能完全单击,这意味着我可以单击按钮的上5个像素。在此之后,按钮不会对悬停甚至单击做出反应。 虽然我试着把按钮放在别的地方,但是它在窗户中间工作,但是它不在窗户的上边。 只是看起来不错。 在Snoop中,按钮上没有任何内容。 这是我的密码,我找不到原因 <Window x:Class="LatikeManager.MainWindow" xmlns="http://schemas.micros

我只是编程了一个没有窗口边框的自己的窗口。所以我的退出按钮只是右上角的一个按钮。此按钮不能完全单击,这意味着我可以单击按钮的上5个像素。在此之后,按钮不会对悬停甚至单击做出反应。 虽然我试着把按钮放在别的地方,但是它在窗户中间工作,但是它不在窗户的上边。

只是看起来不错。

在Snoop中,按钮上没有任何内容。

这是我的密码,我找不到原因

<Window x:Class="LatikeManager.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:LatikeManager"
    mc:Ignorable="d"
    Title="Project LATIKE"  
    Icon="Resources/pcc.ico" 
    Height="800" 
    Width="1000" 
    Background="#FF222525" 
    MinHeight="400" 
    MinWidth="500" 
    WindowStyle="None" 
    AllowsTransparency="True" 
    SizeToContent="Manual"
    ResizeMode="CanResizeWithGrip">
<Border BorderThickness="1">
    <!--complete grid-->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!--title & window settings-->
        <Grid Background="#FF131212">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <!--Title-->
            <StackPanel HorizontalAlignment="Left" Orientation="Horizontal">
                <Image Width="25" Height="25" Margin="2 2 2 2" VerticalAlignment="Center"/>
                <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Foreground="LightGray" FontWeight="Bold">Project LATIKE - Latike Manager</TextBlock>
            </StackPanel>
            <!--Window settings-->
        <StackPanel Orientation="Horizontal" Grid.Column="1">
            <Button>x</Button>
        </StackPanel>
    </Grid>
        <!--menuebar to load different modes-->
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <StackPanel Name="spMenu" Grid.Column="0" Orientation="Horizontal" Background="#FF131212">
                <!--Roommanager-->
                <ToggleButton Name="tbtRoomManager">
                    <ToggleButton.ContentTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <!--<Image VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Stretch="Uniform"/>-->
                                <TextBlock VerticalAlignment="Center"  Margin="5 2 0 0"></TextBlock>
                            </StackPanel>
                        </DataTemplate>
                    </ToggleButton.ContentTemplate>
                </ToggleButton>
                <!--Roomdesigner-->
                <!--<ToggleButton Name="tbtRoomDesigner">
                <ToggleButton.ContentTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Image VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Stretch="Uniform"/>
                            <TextBlock VerticalAlignment="Center"  Margin="5 2 0 0">Raumdesigner</TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ToggleButton.ContentTemplate>
            </ToggleButton>-->
                <!--Settings-->
                <ToggleButton Name="tbtSettings">
                    <ToggleButton.ContentTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                                <!--<Image VerticalAlignment="Center" HorizontalAlignment="Left" Width="25" Height="25" Stretch="Uniform"/>-->
                                <TextBlock VerticalAlignment="Center"  Margin="5 0 0 0"></TextBlock>
                            </StackPanel>
                        </DataTemplate>
                    </ToggleButton.ContentTemplate>
                </ToggleButton>
            </StackPanel>

    </Grid>
        <!--content loader: load and shows the modes-->
        <Grid Name="gdManagerContent" Grid.Row="2" Grid.ColumnSpan="2"/>
        <!--State- and eventbar-->
        <Grid Grid.Row="3" Background="#FF131212" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <!--actual eventbar-->
            <StackPanel Grid.Column="0" Orientation="Horizontal">
                <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" Foreground="White">Ereignisse:</TextBlock>
                <Image Width="25" Height="25" Margin="2 0 2 0" Stretch="Uniform"></Image>
                <TextBlock Foreground="White" MinWidth="100" VerticalAlignment="Center" Margin=" 15 0 0 0"></TextBlock>
            </StackPanel>
            <Grid Width="1" HorizontalAlignment="Right" Background="Gray" />
            <!--linkbar-->
            <StackPanel Margin="5 0 0 0" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Fortschritt :" Width="70" Foreground="Gray" VerticalAlignment="Center"/>
                    <TextBlock Width="70" Foreground="Gray" HorizontalAlignment="Right" VerticalAlignment="Center"></TextBlock>
                    <TextBlock Width="25" Foreground="Gray" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
                    <TextBlock Text="s" Foreground="Gray" HorizontalAlignment="Center" VerticalAlignment="Center"></TextBlock>
                    <Grid Margin="7 0 3 0">
                        <ProgressBar  Width="100" Height="10"></ProgressBar>
                        <StackPanel Width="100" Orientation="Horizontal">
                            <TextBlock Margin="20 0 0 0" Width="25" Foreground="Black" VerticalAlignment="Center"></TextBlock>
                            <TextBlock Width="30" Text="MB/s" Foreground="Black" VerticalAlignment="Center" Margin="2 0 0 0"></TextBlock>
                        </StackPanel>

                    </Grid>
                </StackPanel>
                <Grid Width="1" HorizontalAlignment="Right" Background="Gray" />
                <TextBlock Margin="5 0 0 0" TextAlignment="Right" Width="120" Foreground="Gray" Grid.Column="1" VerticalAlignment="Center"></TextBlock>
                <Image Width="25" Height="25" Stretch="Uniform" Margin=" 10 2 5 5"/>
            </StackPanel>
        </Grid>
        <!--Console-->
        <!--<Grid Grid.Row="4">
                <RichTextBox Name="rtbConsole" BorderBrush="Orange" BorderThickness="0 1 0 0" MinHeight="100" MaxHeight="100" Background="#FF131212" Foreground="White" VerticalScrollBarVisibility="Auto">
                    <FlowDocument>
                        <Paragraph>
                            <Run Text="{Binding ConsoleText}"/>
                        </Paragraph>
                    </FlowDocument>
                </RichTextBox>
        </Grid>-->
    </Grid>
</Border>
</Window>

LATIKE项目-LATIKE经理
x
埃雷格尼塞:

没有主题也是同样的行为。

好吧,假设这是按钮的代码:

<StackPanel Orientation="Horizontal" Grid.Column="1">
    <Button>x</Button>
</StackPanel>

x
你到底在哪里处理点击按钮?您应该给它一个click事件或一些命令处理

<StackPanel Orientation="Horizontal" Grid.Column="1">
    <Button Command="CloseTheApplicationCommand">x</Button>
</StackPanel>

x

如果上述操作不起作用,请检查snoop中确实发生了哪些事件。也许您应该使用“pre…”事件来处理按钮。

我刚刚发现了错误。我只是用它把Windows7向上的功能添加到我的窗口中,而不使用Windows样式

WindowChrome.SetWindowChrome(this, new WindowChrome());
但因为我没有显示边框,所以它是透明的,可以阻挡按钮。
删除此项修复了我的问题。

您可以尝试删除此项,以找到与按钮重叠的部分。我只是使用Snoop,找不到任何与按钮重叠的内容。您可以分享您使用的按钮样式吗?默认按钮将显示如下我仍然无法重现您的问题。不清楚ButtonStyle是如何应用于按钮的。它不在您的示例标记中。@DonKnash复制项目并慢慢删除代码,直到a)它工作了,您现在知道是什么导致了问题,或者b)它仍然不工作,并且您有一个问题,它们是“预览”事件,并且不是OP问题的解决方案。很抱歉,由于一条注释,我刚刚删除了所有事件。在我的应用程序中有一些事件,我可以触发这些事件,但只需按按钮的5个像素即可。