For example screen is 1920*1080 ,but I want to set 2580*1600 for my wpf window size,Is this possible?how can I realize it?
Thank you !
I have a simple task that I want to accomplish: Have a WPF window launch with a Horizontal Alignment that is stretched to the total width of the current screen. I want to achieve a kind of custom Overlay MessageBox (I dont want to use third party controls such as MahApps), I am not using any third party references for this.
Please see what I have achieved so far (Not sure if the image will show, the link is http://imgur.com/e27DyNJ):
I have tried setting the width with a Controller object that I wrote which works, that basically sets the Width, Height, Left and Top to the width of the primary monitor. Downside is the window then pops up on the primary screen, not on the screen that is currently in use.
As far as I know, WPF doesn't have any multi-screen functions. You could PInvoke some native Multiple Display Monitor Functions, wrap them in a managed class and utilize them in that regard, though.
As a workaround, I have done the following:
var screen = System.Windows.Forms.Screen.FromRectangle(new System.Drawing.Rectangle((int)window.Left, (int)window.Top, (int)window.Width, (int)window.Height));
window.Width = screen.WorkingArea.Width;
window.Left = screen.WorkingArea.Left;
where window is the instance of my window I want to resize.
This works with the current screen the window was opened on.
The Popup class has a PlacementTarget which can be used to position the Popup relatively to a UIElement.
Popup p = new Popup();
p.PlacementTarget = someUIElement;
This is ok but in my case I have a BlockUIContainer (as part of a FlowDocument) and I want a Popup to be opened when the mouse cursor enters the BlockUIContainer. The problem is that the BlockUIContainer is NOT an UIElement.
Does anyone know a solution?
Or can anyone suggest how the screen position of a BlockUIContainer (or any other Block) can be determined? (Then one could use absolute positioning to place the Popup.)
Thanks in advance.
I am wondering if there is a way to spawn a window inside a canvas, setting it's movable boundaries to be inside the Canvas. I figured out how to contain a window's movable range within a window but I cannot figure it out for a panel. If you can use this towards a solution, I'm all ears for that too.
Also, is there a way to grab a canvas' Left and Top coordinates?
Thanks in advance!
I'm creating a Silverlight 4 Out Of Browser application. I have my MainPage that will be the "central" application. I want to be able to display another Control next to the MainPage, by using a Popup and I want it to be displayed right next to the MainPage.
How can I get the coordinates of the upper right corner of the MainPage at each moment? (Beware that this MainPage can be moved all over the screen and hence I will need to dynamically get the corner coordinates, in order to display my popup right next to the main window).
Any thoughts on this?
Thank you!!
PS: the code is in C# :-)
When you say "MainPage" are you meaning MainWindow really? Silverlight doesn't have multiple window support yet.
Assuming you do mean the actual mainpage control and you want the Top/Right corner position that would be Canvas.Top and Canvas.Left properties you could get. If you posted some more XAML it might help us answer on what you are trying to do.