Results 1 to 11 of 11

Thread: [RESOLVED] Auto-Resize Controls at Runtime

  1. #1
    Addicted Member
    Join Date
    Nov 10
    Posts
    155

    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
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,791

    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 subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * 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??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  3. #3
    Addicted Member
    Join Date
    Nov 10
    Posts
    155

    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
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,791

    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 subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * 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??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

  5. #5
    Addicted Member
    Join Date
    Nov 10
    Posts
    155

    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 10
    Location
    MSDN Library
    Posts
    256

    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 02
    Location
    Eygelshoven
    Posts
    1,556

    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

  8. #8
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 99
    Location
    Sweden
    Posts
    13,533

    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.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

  9. #9
    Addicted Member
    Join Date
    Nov 10
    Posts
    155

    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
    Addicted Member
    Join Date
    Nov 10
    Posts
    155

    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
    Super Moderator Joacim Andersson's Avatar
    Join Date
    Jan 99
    Location
    Sweden
    Posts
    13,533

    Re: Auto-Resize Controls at Runtime

    Your two duplicate posts have been merged into one.
    Joacim Andersson
    If anyone's answer has helped you, please show your appreciation by rating that answer.
    I'd rather run ScriptBrix...
    Joacim's view on stuff.

    MVP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •