Solved

WPF Sizing a Border so it doesn't go out of view.. remains and fills the page

Posted on 2010-11-10
1
453 Views
Last Modified: 2013-11-12
Hi..
I have border and in that border,  I have another border and in that I have textbox.
I need to keep the borders 'on the page' so that when the text gets huge thet borders remain filled on the page and don't go off the page and get cut off.  How can I size the borders so that they fill the whole  page when the text is large and how can I add scrollview

My current xaml looks like this


                <Border Grid.Row="1" x:Name="brdSearchResults" CornerRadius="3" Padding="5" Margin="10,10,10,10" BorderBrush="Blue"  BorderThickness="1" Background="White">
             
                    <StackPanel Orientation="Vertical">

                        <Border x:Name="brdUserNotesResults" CornerRadius="3" Grid.Row="1" Background="LightGray" BorderThickness="1,1,1,1" Margin="3,3,3,3">
                                                     
                            <StackPanel Orientation="Vertical">
                           
                            <TextBlock x:Name="txtResult"   Margin="5,0,5,5"  FontWeight="Bold"  HorizontalAlignment="Center" VerticalAlignment="Center" />

....................
0
Comment
Question by:JElster
1 Comment
 
LVL 16

Accepted Solution

by:
ToddBeaulieu earned 200 total points
ID: 34137975
WPF isn't like Win Forms when it comes to layout. In fact, it's exactly backwards. You don't set the size of elements and then try to keep their containers relative. You set the containers' sizes and let the elements consume the available space inside them.

In your case, your code is just fine as shown. The problem is upstream. You're probably setting the grid sizes in a way that allows them to get too large for display. If you start with the bare minimum (like what you included here, removing the Grid.Row stuff, you'd see that your textblock and borders always appear perfectly, regardless of how large you size the form.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now