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?

Developer technologies | Windows Presentation Foundation
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 48,711 Reputation points Microsoft External Staff
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.