I want to figure out a way in my silverlight application to set the PageSize on my DataPager based on the maximized size of the window so that the scrollbars do not show when maximized. Any ideas?
Here is how I wound up doing it:
using System.Windows.Browser;
void View_Loaded(object sender, RoutedEventArgs e)
{
Int32 intRowHeight = 30;
Int32 intTopOfFirstRow = 240;
pgrData.PageSize = ((Int32.Parse(HtmlPage.Window.Eval("screen.height").ToString())) - intTopOfFirstRow) / intRowHeight;
.
.
.
Here is a post about checking in JavaScript if the Window is maximized. If you're running in browser, you should be able to call something like this from Silverlight.
http://www.codingforums.com/archive/index.php/t-127058.html
This page succinctly explains how to do it.
Hope this helps.
Related
I am developing one standalone tool in winforms using C#, in which I want the labels to be grows based on the screen resolution.
Kindly help me with the solution.
Below is the solution for this question.
private void Form1_Resize(object sender, EventArgs e)
{
label1.Font = new Font(this.Font.FontFamily, this.Width / 100);//you can set the font size yourself
}
So i'am working with tabControl in windows forms application and i want to make the tabs get full width regardless whether the application window is maximized or not.
When the window isn't maximized everything appears great:
But when the window gets maximized the tabs doesn't get the full width:
Is there any known way to fix this problem?
Thanks in advance
You can achieve this in some way by modifying the ItemSize property as described bellow, else you'd have to draw the tab page selectors yourself.
public Form1()
{
InitializeComponent();
tabControl1.SizeMode = TabSizeMode.Fixed;
tabControl1.ItemSize = new Size((tabControl1.Width / tabControl1.TabPages.Count) - 1, tabControl1.ItemSize.Height);
}
//Hook to form or parent container Resize event, either Resize or ResizeEnd.
private void Form1_ResizeEnd(object sender, EventArgs e)
{
tabControl1.ItemSize = new Size((tabControl1.Width / tabControl1.TabPages.Count) - 1, tabControl1.ItemSize.Height);
}
I have a WPF application where I put on several DotNetBrowser.WPF.WPFBrowserView elements inside a ScrollViewer vertically.
My problem is that these are not scrolling when I start scrolling with the ScrollViewer. I know that this is just an embedded separated window (or something like that) but I have to made this able to scroll.
Is there any way to achive this?
Thank you for any help in advance!
You can solve this by handling ScrollChanged event for the ScrollViewer.
Here's quick example:
scrollViewer.ScrollChanged += delegate (object sender, ScrollChangedEventArgs e)
{
browserView.Browser.SetBounds(-(int)e.HorizontalOffset, -(int)e.VerticalOffset, (int)browserView.ActualWidth, (int)browserView.ActualHeight);
};
You can also try to use lightwight mode.
Browser browser = BrowserFactory.Create(BrowserType.LIGHTWEIGHT);
var browserView = new WPFBrowserView(browser);
I'm currently working on a WPF application which will run on Windows 8.1 tablet and I don't find any posts about the following issue :
My application needs to be full screen, so, I set for my views :
WindowState="Maximized"
WindowStyle="ToolWindow"
All right - my application will be displayed in full screen mode:
But, if I rotate the tablet a space is allocated and the application is not in full screen.
I don't want this scenario to happen, the application should stay always in full screen.
I tried to listen SystemEvents.DisplaySettingsChanged event and manually set full screen:
SystemEvents.DisplaySettingsChanged += Current_SizeChanged;
private void Current_SizeChanged(object sender, EventArgs eventArgs)
{
this.WindowStyle = WindowStyle.None;
this.ResizeMode = ResizeMode.NoResize;
this.WindowState = WindowState.Maximized;
this.UpdateLayout();
}
As you can see, i tried even to update layout, but still, not working!
What is strange, is the fact that if you start the application in any position but not in the normal one, it will work. For ex: if the application is started in portrait mode, rotation will not change the dimensions of the window, but if you run the application starting from landscape mode... the bug appears.
You can debug this issue using Ctrl + Alt + Arrows.
Any suggestions?
Edit: It seems that the problem is caused by keyboard. The reserved zone is for keyboard, but i don't find a way to resize to full screen. Actual width, Width and Desired Width are all the same...
Edit2: This bug can be reproduced only on Windows 8.1
You can use DisplaySettingsChanged event of the SystemEvents class. Here is an example -> How to Detect Screen Rotation
Use a property in viewmodel which will set in the Current_SizeChanged method. Then put a data trigger on this boolean and apply RotateTransform 90deg to your LayoutTransform.
A workaraund for this bug is to listen to DisplaySettingsChanged and manually set windows state to normal and after windows state to maximized, like below :
SystemEvents.DisplaySettingsChanged += Current_SizeChanged;
private void Current_SizeChanged(object sender, EventArgs eventArgs)
{
this.WindowState = WindowState.Normal;
this.WindowState = WindowState.Maximized;
}
This is caused by :
WindowStyle="ToolWindow"
Hope microsoft will solve this bug (I submitted the bug on WPF threads on MSDN). Thank you for your help!
I have a Silverlight 5 Application that we run Out Of Browser. I would like to know if there is some way to set the Out Of Browser Window Height and Width dynamically in code.
Everyone has a different size monitor. I don’t want the people with the larger monitors to be limited to the screen of the smallest size monitor.
I would either base it on the Users Id or if possible detecting the monitor dimensions.
This may help,
private void Application_Startup(object sender, StartupEventArgs e) { MyForm = new MyForm();
this.RootVisual = startupWindow;
this.MainWindow.Width = startupWindow.Width; this.MainWindow.Height = startupWindow.Height; }