locked
How to add Margin and Padding to XAML Grid.RowDefinitions ? RRS feed

Answers

  • Hi ideepaksingh,

    the problem is your fixed size in the RowDefinitions. Instead of the fixed value of 25 you should use Auto. With the fixed value of 25 the Height can't grow and the TextBoxes are clipped. With Auto the Height will grow to the size of your TextBoxes. Below the sample as it should be:

    <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

         


    Thomas Claudius Huber

    "If you can´t make your app run faster, make it at least look & feel extremly fast"

    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    • Marked as answer by ideepaksingh Monday, September 16, 2013 11:15 AM
    Sunday, September 15, 2013 12:16 PM

All replies

  • You can give margin and padding to all controls in XAML.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, September 12, 2013 1:18 PM
    Moderator
  • Hi, Matt thank you for reply I have changed stackpanel to grid layout but when i specify margin to TextBlock. It get squashed.

      Refer this for code:-

    http://social.msdn.microsoft.com/Forums/en-US/fb9061c1-ab58-40a4-9b41-9c9f523e149d/how-to-make-xaml-controlstextbox-in-wpf-to-fill-remaining-space-of-grid


    Deepak Kumar Singh

    Friday, September 13, 2013 9:39 AM
  • What exactly are you putting for margin?


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, September 13, 2013 2:42 PM
    Moderator
  • I just want to add some margin-top/gaps between my textbox.

    For code plz refer above link..

    Thank you Matt for replying.


    Deepak Kumar Singh

    Sunday, September 15, 2013 7:45 AM
  • Hi ideepaksingh,

    the problem is your fixed size in the RowDefinitions. Instead of the fixed value of 25 you should use Auto. With the fixed value of 25 the Height can't grow and the TextBoxes are clipped. With Auto the Height will grow to the size of your TextBoxes. Below the sample as it should be:

    <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

         


    Thomas Claudius Huber

    "If you can´t make your app run faster, make it at least look & feel extremly fast"

    twitter: @thomasclaudiush
    homepage: www.thomasclaudiushuber.com
    author of: ultimate Windows Store Apps handbook | ultimate WPF handbook | ultimate Silverlight handbook

    • Marked as answer by ideepaksingh Monday, September 16, 2013 11:15 AM
    Sunday, September 15, 2013 12:16 PM