WPF不规则窗口和Settings.setting设置示例
2011-03-29 17:47
363 查看
<Window x:Class="WpfApplication_Transparency.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" AllowsTransparency="True" WindowStyle="None" Background="Transparent" MouseLeftButtonDown="Window_MouseLeftButtonDown" Loaded="Window_Loaded" Title="MainWindow" Height="350" Width="525"> <Grid> <Rectangle Fill="Yellow"> </Rectangle> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="10*"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <Label Grid.Row="0" Grid.ColumnSpan="3" x:Name="LabelShow"/> <Label Content="Input" Grid.Row="1" Grid.Column="0"></Label> <TextBox Grid.Row="1" Grid.Column="1" x:Name="TextBoxInfo"/> <Button Grid.Row="1" Click="Button_Click_1" Grid.Column="2" Content="Close and Save"/> </Grid> </Grid> </Window>
using System; using System.Collections.Generic; using System.Linq; using System.Text; 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 WpfApplication_Transparency { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.DragMove(); } private void Button_Click_1(object sender, RoutedEventArgs e) { if (TextBoxInfo.Text != null) { Properties.Settings.Default.Infomation = TextBoxInfo.Text; Properties.Settings.Default.Save(); } this.Close(); } private void Window_Loaded(object sender, RoutedEventArgs e) { LabelShow.Content = Properties.Settings.Default.Infomation; } } }
代码讲解:
在MainWindow.xaml中设置mainwindow的属性如下
AllowsTransparency="True"
WindowStyle="None"
Background="Transparent"
可使用不规则窗口。
相关文章推荐
- WPF不规则窗口和Settings.setting设置示例
- [WPF] 如何为无边框窗口设置阴影效果
- 如何设置不规则窗口GTK
- WPF-拖动面板移动窗口&设置窗口状态
- 设置Maven用户对应的setting.xml配置文件示例
- wpf中如何将窗口设置为透明
- [WPF] 如何为无边框窗口设置阴影效果
- 设置WPF窗口相对于非WPF窗口的位置
- WPF GroupBox样式( 设置窗口样式 设置 ResizeGrip )
- WPF应用程序设置启动时自动打开的第一个窗口的几种方式
- qss样式表笔记大全(三):可设置样式的窗口部件列表(中)(包含相关示例)
- wpf登录窗口示例
- User Settings in WPF 用户设置,在xaml中绑定等
- ApplicationSettingsBase: 关掉WPF 窗口后,再次打开,显示在上次关闭的位置
- flex一个托盘加透明背景和不规则窗口的整理示例
- WPF如何把图片Image控件设置成,当窗口的放大和缩小,跟随着一起变化
- WPF中设置了WindowStyle="None"后,窗口仍然有边框的解决方法
- [C#, WPF] 根据鼠标距离窗口中心的距离设置其背景色
- WPF(6)----窗口大小固定设置
- 【原】创建 WPF 不规则窗口