zoukankan      html  css  js  c++  java
  • WPF中自定义窗体标题栏

    最新文章:Virson's Blog

    这个例子是在看《深入浅出WPF》第5章控件与布局的Canvas控件时,对书上的例子做了一下小扩展;在此记下,以备后用:

    XAML代码:

     1 <Window x:Class="TestCanvas.MainWindow"
     2         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     3         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     4         Title="登录" Height="110px" Width="300px" WindowStartupLocation="CenterScreen" WindowStyle="None" 
     5         MaxHeight="110px" MaxWidth="300px" MinHeight="110px" MinWidth="300px" MouseMove="Mouse_moveHandler"> 
     6     <Canvas>
     7         <TextBlock Text="用户名:" Canvas.Left="12px" Canvas.Top="12px"/>
     8         <TextBox Height="23px" Width="200px" BorderBrush="Black" Canvas.Left="66px" Canvas.Top="9px"/>
     9         <TextBlock Text="密码:" Canvas.Left="12px" Canvas.Top="40.72px" Height="16px" Width="36px"/>
    10         <TextBox Height="23px" Width="200px" BorderBrush="Black" Canvas.Left="66px" Canvas.Top="38px"/>
    11         <Button Content="登录" Width="80px" Height="23px" Canvas.Left="66" Canvas.Top="67px"/>
    12         <Button Content="退出" Width="80px" Height="23px" Canvas.Left="186" Canvas.Top="67px" Click="Close_clickHandler"/>
    13     </Canvas>
    14 </Window>

    CSharp代码:

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Linq;
     4 using System.Runtime.InteropServices;
     5 using System.Text;
     6 using System.Threading.Tasks;
     7 using System.Windows;
     8 using System.Windows.Controls;
     9 using System.Windows.Data;
    10 using System.Windows.Documents;
    11 using System.Windows.Input;
    12 using System.Windows.Media;
    13 using System.Windows.Media.Imaging;
    14 using System.Windows.Navigation;
    15 using System.Windows.Shapes;
    16 
    17 namespace TestCanvas
    18 {
    19     /// <summary>
    20     /// MainWindow.xaml 的交互逻辑
    21     /// </summary>
    22     public partial class MainWindow : Window
    23     {
    24         public MainWindow()
    25         {
    26             InitializeComponent();
    27         }
    28 
    29         public void Close_clickHandler(Object sender, RoutedEventArgs e)
    30         {
    31             this.Close();
    32         }
    33 
    34         private void Mouse_moveHandler(object sender, MouseEventArgs e)
    35         {
    36             if (e.LeftButton == MouseButtonState.Pressed&& e.Source == this) this.DragMove();
    37         }
    38     }
    39 }
  • 相关阅读:
    plsql查询中文乱码
    ORA-12514: TNS:listener does not currently know of service requested in connect
    linux 手动配置ip地址方法
    开机自起tomcat
    (静默安装)Cent OS 6_5(x86_64)下安装Oracle 11g
    Linux下启动Oracle服务和监听程序
    linux下强制安装rpm包
    谷歌浏览器如何将整个网页保存为图片
    C语言移位和位运算
    MySQL连接的使用
  • 原文地址:https://www.cnblogs.com/mawanglin2008/p/2865500.html
Copyright © 2011-2022 走看看