Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hell I have a created my own CustomWindow with a special design. I have a CustomControlLibrary. When I include it a
WPF Application and start the Application i see the new design. But I would like to see the new design in design time.

Here you will see my code of the CustomWindow

C#
    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>



Here you will see my code of the Demo Application:

C#
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>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900