Solved

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

Posted on 2010-11-10
1
452 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
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 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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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

10 Experts available now in Live!

Get 1:1 Help Now