Jump to content

Error using WPF Border property


Recommended Posts

Hi there,

I'm trying to use the PresentationFramwork System.Windows.Controls.Border width property but without luck - I keep getting error 1172.

Does anyone know what is going on please? Any help much appreciated!

Error creating instance of Border in assembly System.Windows.Controls.Border, PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, (System.InvalidOperationException: The calling thread must be STA, because many UI components require this.) <append><b>System.InvalidOperationException</b> in Untitled 3

Thank you,

Martin

wpf border.vi

post-13935-0-96870600-1340102732.png

Link to comment

Can't offer direct help now because I'm on my mobile, but the STA/MTA threading mode issue creeps up from the to time. I last remember this discussion in the context of showing the system folder browser dialog. Maybe searching for that might turn the answer up?

Link to comment

Thank you for that,

For anyone interested I've made the error go away by 'preferred execution system' for the vi to 'user interface'. However I'm now having a value of NaN returned so I'm not sure if I've fixed it or not.

Thanks,

Martin

Link to comment

This is just a guess, but if you are trying to figure out the width of the window border from your VI panel, you are in the wrong area.

Controls.Border is a .NET control, just like a button or a slider. By calling its constructor you have created an instance of this control. The control's width defaults to NaN as you discovered. For .NET controls this means that they sized to their parent. Once the control has a parent it will compute its width which will then be available through the ActualWidth property. Your control has no parent which means it can't compute its width and also means it will never be drawn in any window.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.