namespace _2023742
{
public class tools
{
public static int Jsuan(int a,int b) {
return a + b;
}
}
}
这是我自己创建的一个类库,为什么在wpf里面引用会弹出引用无效不支持该引用
wpf 自定义窗体 并 拖动窗体大小变化 网上普遍 实现都是 win32那一套或者用windowChrome.Shell这两种方式。实际上wpf目前已经集成了windowChrome。那么新的使用方式怎么弄呢?非常简单!
Xaml实现代码
后台都不用写任何代码哟!
<Window x:Class="TestNoBorderWindow"
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"
Title="TestNoBorderWindow"
Width="300"
Height="300"
MinWidth="100"
MinHeight="100"
mc:Ignorable="d">
<Window.Style>
<Style TargetType="Window">
<Setter Property="Background" Value="Transparent" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="CanResize" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="20" />
</Setter.Value>
</Setter>
</Style>
</Window.Style>
<Border Margin="10"
Background="White"
BorderBrush="Red"
BorderThickness="1"
CornerRadius="5"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect BlurRadius="10"
Direction="0"
ShadowDepth="0" />
</Border.Effect>
<Grid />
</Border>
</Window>
当然你也可以直接写成Window的Style
<Window x:Class="TestNoBorderWindow"
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"
Title="TestNoBorderWindow"
Width="300"
Height="300"
MinWidth="100"
MinHeight="100"
mc:Ignorable="d">
<Window.Style>
<Style TargetType="Window">
<Setter Property="Background" Value="Transparent" />
<Setter Property="WindowStyle" Value="None" />
<Setter Property="ResizeMode" Value="CanResize" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CaptionHeight="30" ResizeBorderThickness="20" />
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Window">
<Border Padding="10">
<Border Background="White"
BorderBrush="Red"
BorderThickness="1"
CornerRadius="5"
SnapsToDevicePixels="True">
<Border.Effect>
<DropShadowEffect BlurRadius="10"
Direction="0"
ShadowDepth="0" />
</Border.Effect>
<ContentPresenter />
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Style>
</Window>
先看看GIF