amitairoa Posted July 27, 2008 Posted July 27, 2008 Hi! I'm working on a WPF program in C#. I'm still a bit new to WPF. I wanted to know how to set a control's position(image for instance)- from code. There isn't a "img.left" in WPF. I don't know how to control an image's position by code. Can someone please help me? Thanks! Quote
MrPaul Posted July 27, 2008 Posted July 27, 2008 No absolute positioning in WPF There is no absolute positioning in WPF. Instead, controls are automatically placed and sized according to their margins, the margins of adjacent controls, and the padding of their container. The system is very similar to that used in web pages. Good luck :cool: Quote Never trouble another for what you can do for yourself.
amitairoa Posted July 27, 2008 Author Posted July 27, 2008 Re: No absolute positioning in WPF There is no absolute positioning in WPF. Instead, controls are automatically placed and sized according to their margins, the margins of adjacent controls, and the padding of their container. The system is very similar to that used in web pages. Good luck :cool: I'm still new to WPF- can you please help me? How do I do this: I want an image to be at a certain point on the screen- which it is already. Then- at a timer tick- I want the image to move to a different location. Maybe you could please explain a bit more about the WPF positioning? Thanks! Quote
Nate Bross Posted July 28, 2008 Posted July 28, 2008 Look into the SetLeft and SetTop methods. I don't know if they are best practice or not, but they should help you out. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
Administrators PlausiblyDamp Posted July 28, 2008 Administrators Posted July 28, 2008 It really depends on exactly what you want to do as which method may be best, are you using the timer to drive some animation or is it being used for some other reason? SetLeft and SetTop (methods of the Canvas object) will certainly give you control over the position of a visible element however if you are looking at just doing animation then WPF has a pretty sophisticated system built in that may better suit your needs. Out of curiosity could you give a bit more detail about what you are trying to do? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
amitairoa Posted July 29, 2008 Author Posted July 29, 2008 It really depends on exactly what you want to do as which method may be best, are you using the timer to drive some animation or is it being used for some other reason? SetLeft and SetTop (methods of the Canvas object) will certainly give you control over the position of a visible element however if you are looking at just doing animation then WPF has a pretty sophisticated system built in that may better suit your needs. Out of curiosity could you give a bit more detail about what you are trying to do? Hi! The timer doesn't drive an animation. The timer just changes an image into a certain picture. It's basically a program for teaching something to kids. Quote
Administrators PlausiblyDamp Posted July 29, 2008 Administrators Posted July 29, 2008 Could you not just simply load the image into the control at runtime rather than changing it's position? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
amitairoa Posted July 29, 2008 Author Posted July 29, 2008 Could you not just simply load the image into the control at runtime rather than changing it's position? No. There's an audio file, and when the speaker says something- a different image appears. At one point- I want tthe image to be at a different position. Quote
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.