Scroll To Top

WPF popup UserControl

By Amal ES Dec 24, 2011
Learn how to create UserControl in WPF.
Create a WPF project and create a UserControl. The UserControl contains one calendar.
<UserControl x:Class="WpfApplication6.UserControl1 "
              mc:Ignorable="d" Name
             d:DesignHeight="158" d:DesignWidth="183">
    <Grid Height="154" Width="186">
        <Calendar Height="150" HorizontalAlignment="Left" Name="calendar1" VerticalAlignment="Top" Width="189" />
In the main window create a popup xaml code.Create a reference of theUserControl. Then call the UserControl inside the popup.
<Window x:Class="WpfApplication6.MainWindow"
        Title="MainWindow" Height="350" Width="525">
        <ToggleButton Name = "button" Height="45" Width="154" Foreground="Green">
                <ControlTemplate  TargetType="ToggleButton">
                    <TextBlock> Click here to view the popup</TextBlock>
        <Popup IsOpen="{Binding IsChecked, ElementName=button}">
            <Border Background="Green">