我刚刚编写了一个没有Windows边框的自己的窗口。所以我的退出按钮只是右上角的一个按钮。这个按钮不是完全可点击的,这意味着我只需点击按钮的上5个像素。之后,按钮不会响应悬停甚至点击。 虽然我试图将按钮放在其他位置,但是它正在窗口中间工作,但它不能在窗口的上方工作。
这是我的代码,我无法找到原因。
<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>
没有主题是相同的行为。
答案 0 :(得分:0)
好吧,假设这是你的按钮代码:
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button>x</Button>
</StackPanel>
你到底在哪里处理点击按钮?你应该给它一个点击事件或一些命令处理。
<StackPanel Orientation="Horizontal" Grid.Column="1">
<Button Command="CloseTheApplicationCommand">x</Button>
</StackPanel>
如果上述方法无效,请检查侦听中的哪些事件确实发生。也许你应该使用“pre ...”事件处理按钮。
答案 1 :(得分:0)
我刚发现错误。我只是使用它来将Windows 7向上功能添加到我的窗口而没有Windows风格。
WindowChrome.SetWindowChrome(this, new WindowChrome());
但是因为我没有显示边框,所以它是透明的阻挡按钮。 删除这个解决了我的问题。