Results 1 to 11 of 11

Thread: [RESOLVED] Auto-Resize Controls at Runtime

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    220

    Resolved [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

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Auto-Resize Controls at Runtime

    Use the Anchor properties to determine how you want it to resize....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    220

    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.

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    220

    Re: Auto-Resize Controls at Runtime

    Quote Originally Posted by techgnome View Post
    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.

  6. #6
    Hyperactive Member marniel647's Avatar
    Join Date
    Aug 2010
    Location
    MSDN Library
    Posts
    259

    Re: Auto-Resize Controls at Runtime

    Quote Originally Posted by kumika View Post
    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

  7. #7
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: Auto-resize controls at Runtime - WPF App

    Can't you use horizontalAllignment=stretch?
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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.

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    220

    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

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Nov 2010
    Posts
    220

    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

  11. #11
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    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
  •  



Click Here to Expand Forum to Full Width