Solved

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

Posted on 2010-11-10
1
459 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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