public class CustomWindow : Window { static CustomWindow() { DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomWindow), new FrameworkPropertyMetadata(typeof(CustomWindow))); } public void button1_Click(object sender, RoutedEventArgs e) { this.Close(); } } <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cc ="clr-namespace:WpfCustomControlLibrary1" > <Style TargetType="{x:Type cc:CustomWindow}"> <Setter Property="AllowsTransparency" Value="True"/> <Setter Property="WindowStyle" Value="None"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type cc:CustomWindow}"> <Border BorderBrush="Green" BorderThickness="1" CornerRadius="10" removed="Aquamarine"> <AdornerDecorator> <ContentPresenter ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" Content="{TemplateBinding ContentControl.Content}" /> </AdornerDecorator> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
namespace WpfApplication1 { /// <summary> /// Interaktionslogik für MainWindow.xaml /// </summary> public partial class MainWindow : CustomWindow { public MainWindow() { InitializeComponent(); } } <my:CustomWindow x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1" Title="MainWindow" Height="350" Width="525"> <Grid> <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="74,84,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" /> </Grid> </my:CustomWindow>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)