-
Aug 1st, 2012, 06:38 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Auto-Resize Controls at Runtime
I have created a stackpanel (Dim myPanel as New StackPanel) and placed it inside a Grid with its width set to Auto. I set the width for the panel to: myPanel.Width = 500. Now when running the window in other screens the parent grid displays fine but the panel is much smaller than I want. How do I set the Width for the stackpanel sothat it resizes correctly in every screen. I guess there is no code needed in order to figure out the solution. Thanks for assisting.
Last edited by Joacim Andersson; Aug 2nd, 2012 at 05:26 AM.
Reason: Marked as resolved
-
Aug 1st, 2012, 06:46 AM
#2
Re: Auto-Resize Controls at Runtime
Use the Anchor properties to determine how you want it to resize....
-tg
-
Aug 1st, 2012, 07:08 AM
#3
Thread Starter
Addicted Member
Re: Auto-Resize Controls at Runtime
Anchor properties works with the Winforms not the WPF windows. This is a WPF app. However, the control is set dynamically.
-
Aug 1st, 2012, 07:36 AM
#4
Re: Auto-Resize Controls at Runtime
Since this is a WPF issue, I'm going to ask the mods to move it to the WPF section...
*sigh*
-tg
-
Aug 1st, 2012, 08:08 AM
#5
Thread Starter
Addicted Member
Re: Auto-Resize Controls at Runtime
Originally Posted by techgnome
Since this is a WPF issue, I'm going to ask the mods to move it to the WPF section...
*sigh*
-tg
Well, since we are talking about Runtime rather than XAML coding, this must be a vb.net. Issue NOT a WPF issue. I know how to set width relatively in XAML. What I want is Runtime coding which is a VB.net issue. I hope I am correct. I stand to be corrected though.
-
Aug 1st, 2012, 09:10 AM
#6
Hyperactive Member
Re: Auto-Resize Controls at Runtime
Originally Posted by kumika
Well, since we are talking about Runtime rather than XAML coding, this must be a vb.net. Issue NOT a WPF issue. I know how to set width relatively in XAML. What I want is Runtime coding which is a VB.net issue. I hope I am correct. I stand to be corrected though.
tech suggested to move this to wpf section because this section is all about .net winforms. so i think you can have the answer immediately when this post is transfer to wpf section
-
Aug 1st, 2012, 03:40 PM
#7
Re: Auto-resize controls at Runtime - WPF App
Can't you use horizontalAllignment=stretch?
-
Aug 1st, 2012, 05:27 PM
#8
Re: Auto-Resize Controls at Runtime
This site is called VBForums (plural) for a reason. It's all about VB. Well, we do also have a few forums for other languages but those are clearly marked as such. All the others are VB forums and that include the WPF forum. This question is clearly about WPF, even though it's not about the XAML side of that coin. This forum is the general VB.Net forum, for all VB.Net question that doesn't fit into any of the other more specific forums we have.
So for you, the OP, to get the best and quickest answer directly related to your question I have now moved it to the WPF forum.
-
Aug 1st, 2012, 06:09 PM
#9
Thread Starter
Addicted Member
Re: Auto-resize controls at Runtime - WPF App
Using the .stretch property does not help in my case. What I have done, which proves to be the best solution is: <myPanel.width=workarea.width>. Thanks
-
Aug 1st, 2012, 06:23 PM
#10
Thread Starter
Addicted Member
Re: Auto-Resize Controls at Runtime
I have found the answer. All I needed to do was: <mypanel.width=workarea.width>. In this way the panel width resizes universally, at least according to the three screens I used to test. Thanks
-
Aug 2nd, 2012, 05:24 AM
#11
Re: Auto-Resize Controls at Runtime
Your two duplicate posts have been merged into one.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|