WPF Window异形窗口演示
我们先通过简单的效果展示,切换展示不同图片:

我们先定义图片资源文件,我们可以在window资源中定义,下面的在app.xaml文件来定义:
<Application x:Class="WPF异形窗口演示.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ImageBrush ImageSource="1.jpg" x:Key="key1"></ImageBrush>
<ImageBrush ImageSource="2.jpg" x:Key="key2"></ImageBrush>
</Application.Resources>
</Application>
然后通过Combox控件来进行资源样式切换
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 WPF异形窗口演示
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.comboBox1.Items.Add("样式1");
this.comboBox1.Items.Add("样式2");
this.comboBox1.Items.Add("样式3");
this.comboBox1.SelectedIndex = ;
}
private void Grid_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove(); // this.Margin = new Thickness(10,10,10,10);
}
} private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (this.comboBox1.SelectedValue.ToString() == "样式1")
{
//通过uri指向图片位置
this.Background = new ImageBrush(new System.Windows.Media.Imaging.BitmapImage(new Uri("3.jpg", UriKind.Relative))); ;
}
else if (this.comboBox1.SelectedValue.ToString() == "样式2")
{
//通过资源文件获取
this.Background = (ImageBrush)Application.Current.Resources["key1"]; }
else if (this.comboBox1.SelectedValue.ToString() == "样式3")
{
this.Background = (ImageBrush)Application.Current.Resources["key2"]; }
}
}
}
我们可以通过这样的方式来动态实现不同效果展示
示例小demo:
WPF Window异形窗口演示的更多相关文章
- WPF window 子窗口反馈效果(抖动/阴影渐变)
当设置了owner的子窗口显示后,点击子窗口外部,需要一种反馈机制(反馈动画). 实现: 1.触发源 每次点击子窗口外部,即母窗口时,事件捕捉如下 HwndSource hwndSource = Pr ...
- WPF Window对象
户通过窗口与 Windows Presentation Foundation (WPF) 独立应用程序进行交互.窗口的主要用途是承载可视化数据并使用户可以与数据进行交互的内容.独立 WPF 应用程序使 ...
- 使用Unity3d做异形窗口
项目马上上线,因为之前的登录器是使用VS2010的MFC做的,在很多电脑上会提示缺失mfcXXXX.dll,中间找寻这种解决方案,最后确定将vcredist2010_x86和我的程序打包到安装包里面, ...
- WPF 显示模态窗口和窗体
<WPF编程宝典——使用C# 2008和.NET 3.5(第2版)>第25章与Windows窗体的互操作,本章将介绍用于集成Windows窗体和WPF内容的不同策略.还将分析如何在应用程序 ...
- [WPF疑难]避免窗口最大化时遮盖任务栏
原文 [WPF疑难]避免窗口最大化时遮盖任务栏 [WPF疑难]避免窗口最大化时遮盖任务栏 周银辉 WPF窗口最大化时有个很不好的现象是:如果窗口的WindowStyle被直接或间接地设置为None后( ...
- 【转】WPF中的窗口的生命周期
原文地址:http://www.cnblogs.com/Jennifer/articles/1997763.html WPF中的窗口的生命周期 WPF中所有窗口的基类型都是System.Windows ...
- WPF编程,窗口保持上次关闭时的大小与位置。
原文:WPF编程,窗口保持上次关闭时的大小与位置. 版权声明:我不生产代码,我只是代码的搬运工. https://blog.csdn.net/qq_43307934/article/details/8 ...
- 一个最简单的Delphi2010的PNG异形窗口方法
同事演示了一个.NET的的PNG异形窗口.挺漂亮.于是也想用Delphi显摆一个. 关于Delphi用PNG做异形窗口的资料有不少.都是用GDIPlus或者TPNGImage组件加载PNG图像做的.但 ...
- WPF编程学习——窗口
转自 http://www.cnblogs.com/libaoheng/archive/2011/11/18/2253751.html 本文目录 1.窗口的外观 2.窗口的位置 3.窗口的大小 4.窗 ...
随机推荐
- Sublime_text3怎么发现PHP语法错误?
昨晚因为php的某个变量代码写错了,sublime又没有提示语法错误.弄了许久,一段段的调试,最后才知道是取到的变量是空的 sublime可以提示php语法错误 在sublime写完了php代码后,如 ...
- List<T>实体去重分组:
实体去重分组: //实体类 public class Province { public string id { get; set; } public string name { get; set; ...
- Yet Another 10 Common Mistakes Java Developers Make When Writing SQL (You Won’t BELIEVE the Last One)--reference
(Sorry for that click-bait heading. Couldn’t resist ;-) ) We’re on a mission. To teach you SQL. But ...
- iOS 应用性能测试的相关方法、工具及技巧
用户不喜欢等待.他们不关心也不应该关心一个应用初始化的时候需要什么,他们只想尽快地完成他们的任务.你的应用应该几乎是瞬间启动的,其界面应当如丝般顺滑.在充满竞争的软件市场中,应用的性能是关键的优势之一 ...
- centos6.7 install chrome
1.yum仓库 (如果用rpm包安装 可以忽略此步) vim /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrom ...
- CentOS7上Nginx的使用
Nginx 的启动 指定配置文件的方式启动nginx # nginx -c /etc/nginx/nginx.conf 对于yum安装的nginx,使用systemctl命令启动 # systemct ...
- Grant-Permission.ps1
Grant-Permission.ps1 Download the EXE version of SetACL 3.0.6 for 32-bit and 64-bit Windows. Put set ...
- 8个开发必备的PHP功能(转)
又是好几天没写博客,今天看到了个不错的文章,就转载到自己的博客,好以后查询方便. 1.传递任意数量的函数参数 我们在.NET或者JAVA编程中,一般函数参数个数都是固定的,但是PHP允许你使用任意个数 ...
- Quarzt.NET的Cron表达式理解
网上关于Quarzt.NET的Cron表达式介绍有很多,但都是基本的语法,稍微深入一些的就没有了. 基本语法介绍请参看: http://www.cnblogs.com/lzrabbit/archive ...
- HTTP请求方式中get和post的区别
表单提交中get和post方式的区别有5点 1.get是从服务器上获取数据,post是向服务器传送数据. 2.get是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一 ...