copy label in wpf application

Partha Mandayam 91 Reputation points
2022-10-12T13:24:40.207+00:00

I have one label control. Im trying to copythat and create another label below it but when I paste it always goes in the same place
Can't i just copy and paste controls like in asp.net?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,682 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 40,786 Reputation points Microsoft Vendor
    2022-10-13T02:57:50.303+00:00

    Hi,@Partha Mandayam . Welcome Microsoft Q&A.
    As Viorel-1 said, there are many controls for Layout in wpf, such as Grid, StackPanel, Canvas and so on. They each have different characteristics and usage methods. You could use layout controls as needed.
    When you duplicate a control without setting another row and column for the control, it will be in the same position. You could set up rows and columns for the Controls in Grid.

     <Grid>  
            <Grid.ColumnDefinitions>  
                <ColumnDefinition/>  
                <ColumnDefinition/>  
            </Grid.ColumnDefinitions>  
            <Label Grid.Column="0" Content="hello" Width="100" Height="50"/>  
            <Label Grid.Column="1" Content="hello" Width="100" Height="50"/>  
        </Grid>  
    

    StackPanel arranges child elements into a single line that can be oriented horizontally or vertically. Where you copy controls it will be arranged vertically by default.

    For more controls, you can learn in the linked page.

    ----------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Partha Mandayam 91 Reputation points
    2022-10-27T07:05:07.537+00:00

    You haven't answered my question
    How to see the xaml of a cs wpf form in visual studio?

    0 comments No comments