Click here to Skip to main content
15,885,366 members
Articles / Desktop Programming / WPF

WPF Draggable Label

Rate me:
Please Sign up or sign in to vote.
4.63/5 (16 votes)
13 Apr 2010CPOL3 min read 62.5K   6.3K   42  
WPF label control that can be dragged and resized at runtime
<Window x:Class="DraggableLabelTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Main Window" Height="346" Width="464" Loaded="Window_Loaded">
    <Grid>
        <Label Margin="12,9,0,0" Name="label1" VerticalAlignment="Top" HorizontalAlignment="Left" Height="25.96" Width="72.97">Name :</Label>
        <TextBox Height="23" Margin="91,12,12,0" Name="nameTextBox" VerticalAlignment="Top" MinHeight="20" MinWidth="60" />
        <Label Height="25.96" HorizontalAlignment="Left" Margin="12,38,0,0" Name="label2" VerticalAlignment="Top" Width="72.97">Address :</Label>
        <TextBox Margin="91,41,12,202" Name="addressTextBox" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" MinHeight="20" MinWidth="60" />
        <Label HorizontalAlignment="Left" Margin="12,0,0,173" Name="label3" Width="72.97" Height="26" VerticalAlignment="Bottom">Email :</Label>
        <TextBox Margin="91,0,12,173" Name="emailTextBox" Height="23" VerticalAlignment="Bottom" MinHeight="20" MinWidth="60" />
        <Label HorizontalAlignment="Left" Margin="12,0,0,144" Name="label4" Width="72.97" Height="26" VerticalAlignment="Bottom">Country :</Label>
        <TextBox Margin="91,0,12,144" Name="countryTextBox" MinHeight="20" MinWidth="60" Height="23" VerticalAlignment="Bottom" />
        <Label HorizontalAlignment="Left" Margin="12,0,0,115" Name="label5" Width="72.97" Height="25.96" VerticalAlignment="Bottom">Age :</Label>
        <TextBox Margin="91,0,12,115" Name="ageTextBox" MinHeight="20" MinWidth="60" Height="23" VerticalAlignment="Bottom" />
        <Label Height="25.96" HorizontalAlignment="Left" Margin="12,0,0,83" Name="label6" VerticalAlignment="Bottom" Width="72.97">Gender :</Label>
        <ComboBox Height="23" Margin="91,0,12,86" Name="genderComboBox" VerticalAlignment="Bottom" MinHeight="20" MinWidth="60">
            <ComboBoxItem>Male</ComboBoxItem>
            <ComboBoxItem>Female</ComboBoxItem>
        </ComboBox>
        <my:DatePicker Height="25" Margin="91,0,12,55" Name="dateDatePicker" VerticalAlignment="Bottom" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" MinHeight="20" MinWidth="60" />
        <Label Height="25.96" HorizontalAlignment="Left" Margin="12,0,0,55" Name="label7" VerticalAlignment="Bottom" Width="72.97">Date :</Label>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,0,12,26" Name="printButton" VerticalAlignment="Bottom" Width="75" Click="printButton_Click">Print</Button>
        <Button Height="23" HorizontalAlignment="Right" Margin="0,0,93,26" Name="layoutButton" VerticalAlignment="Bottom" Width="75" Click="layoutButton_Click">Layout</Button>
    </Grid>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior)
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions