您的位置:首页 > Web前端 > CSS

制作自定义样式的窗口

2014-05-25 16:54 162 查看
不使用windows自带的窗口样式,使用自定义的客户区,

<Window xmlns:my="clr-namespace:MiniFileTransferClient.Presentation.WPF.UILogic.ShowPanels"  x:Class="MiniFileTransferClient.Presentation.WPF.MiniFileTransferViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MiniFileTransferViewer"  WindowStyle="None"  AllowsTransparency="True"
MouseLeftButtonDown="Window_MouseLeftButtonDown"  StateChanged="Window_StateChanged" Height="530" Width="395"
Background="Transparent">
<Border   Height="530" Width="395"  BorderBrush="Gray" BorderThickness="0"   CornerRadius="5,5,5,5">
<Border.Background>
<ImageBrush ImageSource="/MiniFileTransferClient.Presentation.WPF;component/Images/zhujiemian.png"/>
</Border.Background>
</Border>
</Window>


其中WindowStyle="None"、AllowsTransparency="True" 、Background="Transparent"这三个属性都是要设定的。由于现在默认的非客户区没有了,按下鼠标是不能拖动窗口的,必须在设定鼠标左键按下时的情况,就有了MouseLeftButtonDown="Window_MouseLeftButtonDown" 事件对应的代码:

private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
this.DragMove();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: