?
Solved

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

Posted on 2010-11-10
1
Medium Priority
?
460 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 800 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

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 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…

752 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