MartinMcD Posted June 19, 2012 Report Share Posted June 19, 2012 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 Quote Link to comment
mje Posted June 19, 2012 Report Share Posted June 19, 2012 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? Quote Link to comment
MartinMcD Posted June 19, 2012 Author Report Share Posted June 19, 2012 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 Quote Link to comment
GregR Posted June 19, 2012 Report Share Posted June 19, 2012 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. Quote Link to comment
MartinMcD Posted June 20, 2012 Author Report Share Posted June 20, 2012 Thanks Greg, sounds like I am in the wrong area - thank you for clarifying for me. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.