I started to develop my first UWP App (just for fun). While debugging I noticed that the content would not adapt correctly when resizing the window. I started over with an empty app to see, if it was a general problem: it is.
TL;DR:
Why does this happen when resizing the window larger (beyond 1246x936 px)? Notice the issue on the very right.
That's the XAML code:
<Page
x:Class="App2.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:App2"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
mc:Ignorable="d">
<Grid Background="White">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="3*" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Background="Blue" />
<Grid Grid.Column="1" Background="Red" />
</Grid>
</Page>
Little late but for posterity as this issue still comes up:
This behavior is most likely related to UWP and your video drivers. I have had this issue and it also extended into official Microsoft Windows Store UWP apps (Weather, Calc, etc) verifying it was not something I caused.
If you're lucky and have video driver updates, install them and it will likely fix the issue (it did for me on two different computers, one with an AMD card the other with Intel graphics). If your video drivers are out of support there may not be a path forward (although the app would work on workstations whose drivers did render it correctly).
There are a few tips on this thread that -may- work for workarounds for yourself (but aren't ideal if you're distributing your program and actually need it to render consistently).
https://superuser.com/questions/1376099/windows-10-uwp-not-rendering-fully
Run Performance Options (SystemPropertiesPerformance.exe) and uncheck "Show window contents while dragging". Then reboot.
Resize the window, then close and reopen the application, and it might then be of the right size.
Related
If I create a new WPF application with a simple empty window like the code shown below, I find that all applications which are covered by the WPF app lost touch or stylus reaction. This can only be reproduced when Windows 10 is upgraded to 1803 (10.0.17134.0).
<Window x:Class="TheWPFCoveringWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None" WindowState="Maximized"
AllowsTransparency="True" Background="Transparent"
Topmost="True">
<Button Content="Test" Width="200" Height="100" />
</Window>
I wrote another WPF application to find out what happened. So I add a StylusDown event to the Window like the code shown below:
// This code is in another WPF application.
private void OnStylusDown(object sender, StylusDownEventArgs e)
{
// Set a breakpoint here.
}
But the breakpoint never reached until I closed the transparent WPF window which is on top.
I pushed the very simple code to GitHub: dotnet-campus/TouchIssueOnWindows10.0.17134. Cloning it might help a little.
Why does this happen and how to solve it? Any reply is appreciated.
Updated
Microsoft has fixed this issue in .NET Framework August 2018 Preview of Quality Rollup.
August 30, 2018—KB4346783 (OS Build 17134.254)
Addresses an issue where touch and mouse events were handled differently in Windows Presentation Foundation (WPF) applications that have a transparent overlay window.
Original
After a whole week's debugging, I finally find out the solution.
Just add a ResizeMode="NoResize" property for the Window as the code shown below:
<Window x:Class="TheWPFCoveringWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None" WindowState="Maximized"
AllowsTransparency="True" ResizeMode="NoResize"
Background="Transparent" Topmost="True">
<Button Content="Test" Width="200" Height="100" />
</Window>
#lindexi has posted this issue and this solution into his post. If you want more information about this issue, read win10 17025 touch bug - lindexi for more details. (This post is written in multiple languages, so you'll miss nothing even if you ignore the unknown characters.)
Actually, I still can't figure out why this property helps.
Could anyone explain the reason for this issue?
I'm building a Windows 8 prototype for a large touch enabled 4K screen. My client has a library of existing HTML5 games (the game source is unavailable) they want multiple people to be able to play these browser games on the 4K display at once.
I've inserted 2 WebViews into my app and the games load fin; but only one game can have focus at once, forcing every other game into it's pause screen (automatic behavior in the game when the browser doesn't have focus).
My question is: Is their a way I can prevent the WebView from losing focus or prevent it from knowing that it lost focus? My existing XAML looks like this:
<Grid x:Name="MainGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".5*"></ColumnDefinition>
<ColumnDefinition Width=".5*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<WebView Name="LeftBrowser"
Grid.Column="0"
Source="{Binding LeftBrowserURL, ElementName=browserWin8Window}"/>
<WebView Name="RightBrowser"
Grid.Column="1"
Source="{Binding RightBrowserURL, ElementName=browserWin8Window}"/>
</Grid>
Tldr: I have mutiple WebViews in my Windows Modern app, is there a way I can make them all think they have focus at once?
P.S.: if this is easily done in something else that runs on Windows, please tell me.
If anyone else needs to do something like this in the future, I solved my problem using the WPF version of CefSharp with a custom IWpfFocusHandler.
I am making a WPF program in C# in Visual Studio 2013 and I am using the Ribbon component. So far I've only written XAML for the Ribbon and a few buttons on it, and have only modified the C# file by adding using System.Windows.Controls.Ribbon; and subclassing RibbonWindow instead of Window. I remembered to add a reference to the required .dll in Visual Studio for the Ribbon.
When I run the program, the titlebar is really covered up:
Setting the Ribbon to have HorizontalAlignment="Left" makes it look like this:
I'm pretty new to WPF, C# and Visual Studio, so I don't have any idea what's wrong here. I have pasted my XAML code below (omitting the tab groups and application menu):
<RibbonWindow
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Custom="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon" x:Class="SwaagPaiNT.MainWindow"
Title="Swaag PaiNT" Height="350" Width="525">
<Grid>
<Custom:Ribbon HorizontalAlignment="Stretch" VerticalAlignment="Top">
<Custom:Ribbon.HelpPaneContent>
<Custom:RibbonButton Name="what" ToolTip="whachunee" />
</Custom:Ribbon.HelpPaneContent>
<Custom:Ribbon.QuickAccessToolBar>
<Custom:RibbonQuickAccessToolBar>
<Custom:RibbonButton x:Name="SAVE" ToolTip="BLAZE IT"/>
<Custom:RibbonSplitButton x:Name="Undo">
<Custom:RibbonSplitMenuItem Header="CANNOT UNDO MORE" />
</Custom:RibbonSplitButton>
</Custom:RibbonQuickAccessToolBar>
</Custom:Ribbon.QuickAccessToolBar>
</Custom:Ribbon>
</Grid>
</RibbonWindow>
This is a Windows 7 Professional 32-bit system.
But your problem is that everything is painted as it should be - Ribbon knows nothing about those close and minimize buttons - it is just given some space to be painted on.
To change its looks and behaviours either use templates, create a user control or directly subclass the Ribbon(it is not the usual way, but sometimes you really want to encapsulate your control).
<Window>
<Grid>
...
<MyRibbon Grid.Row="0" .../>
<Ribbon Grid.Row="1" Template={StaticResource MyRibbonTemplate} .../>
</Grid>
</Windows>
EDIT:
Sorry, I was a bit unattentive and never looked at RibbonWindow. I've actually never seen or used RibbonWindow. What I've written before was nearly completely wrong. Thank you for pointing it. Now to the problem.
Such behaviour indicates that the Ribbon control is not integrated with the RibbonWindow as it should be, so you could:
Try MSDN example in place of your code. I don't see any fundamental differences, but who knows. If it works - we will know that there is some simple problem in XAML or code-behind. If not - try next
Try to change the targeted .NET version(Try the highest possible).
Try to change the visual style in Windows(simplified to Aero or to Classic).
There are could be some problems with manually changed inheritance of your windows class to RibbonWindow . Window's code-behind file is actually partial class. I am not sure how it may work in such a way, but that's a possible direction to look in.
P.S.: I will give a try to it by myself later and write about any results.
EDIT:
I've downloaded ribbon controls libraries and tried the MSDN example in Windows 8.1 with Visual Studio 2013 for .NET 4.5 - everything worked fine. But when I changed the targeted framework to 4.0 the Ribbon control blackened the entire line with title. Nonetheless I'll try the example in Win 7 with VS2010.
EDIT:
Such code worked for me in Win7 VS2010 targeting .NET 4.0:
<ribbon:RibbonWindow x:Class="SwaagPaiNT.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
Title="MainWindow"
x:Name="RibbonWindow"
Width="640" Height="480">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ribbon:Ribbon x:Name="Ribbon" Title="Ribbon Title">
<ribbon:Ribbon.HelpPaneContent>
<ribbon:RibbonButton />
</ribbon:Ribbon.HelpPaneContent>
<ribbon:Ribbon.QuickAccessToolBar>
<ribbon:RibbonQuickAccessToolBar >
<ribbon:RibbonButton x:Name="QATButton1"/>
<ribbon:RibbonButton x:Name="QATButton2"
/>
</ribbon:RibbonQuickAccessToolBar>
</ribbon:Ribbon.QuickAccessToolBar>
<ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonApplicationMenu >
<ribbon:RibbonApplicationMenuItem Header="Hello _Ribbon"
x:Name="MenuItem1"
/>
</ribbon:RibbonApplicationMenu>
</ribbon:Ribbon.ApplicationMenu>
<ribbon:RibbonTab x:Name="HomeTab"
Header="Home">
<ribbon:RibbonGroup x:Name="Group1"
Header="Group1">
<ribbon:RibbonButton x:Name="Button1"
Label="Button1" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
</ribbon:Ribbon>
</Grid>
</ribbon:RibbonWindow>
using Microsoft.Windows.Controls.Ribbon;
namespace SwaagPaiNT
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}
The only real difference between your code and the shown above is in the
<RibbonWindow
...
xmlns:Custom="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
Your code uses xml schema to identify ribbon and not the clr-namespace as MSDN shows,
also RibbonWindow is used without any namespace prefix.
I hope that it will help.
I am trying to change the background color of my application in visual studio (XAML) to White (or, ApplicationPageBackgroundTheme / or whatever it's called) and it doesn't work. When I debug, it just shows a black background.
When I go to the Devices pane and select the default color theme to "Light", it makes everything on the screen white, even the text and the background.
When I change the background of the colors in xaml, at runtime it gets changed back to black!
I've searched, but haven't found any information. Is this a known bug? This has never happened before. I am using Visual Studio 2012 Ultimate.
<Page
x:Class="hjgjhgjg.MainPage"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:hjgjhgjh"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Background="White">
<Grid Style="{StaticResource LayoutRootStyle}" Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="140" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="False" Style="{StaticResource BackButtonStyle}" />
<TextBlock x:Name="pageTitle" Grid.Column="1" Text="gfdgfdg" Style="{StaticResource PageHeaderTextStyle}" />
</Grid>
</Grid>
</Page>
Hard to know exactly what's going on without more of the app/styles, but an easy way to change theme is to use the Application object's RequestedTheme property.
For example, in App.xaml, set RequestedTheme="Light" as a property of the Application element:
<Application
x:Class="App1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
RequestedTheme="Light">
This can be helpful because the Light theme will then affect all pages and automatically changes text/buttons/etc. to black instead of everything being white if you only make the background color white.
This walkthrough covers this and how to override default styles with your own custom ones:
Part 1: Create a "Hello, world" app (Windows Store apps using C#/VB and XAML)
BTW, the Device pane doesn't change app settings, but simulates in design view how the app would appear with various device features/settings (screen, theme, etc.) So while it may look like one theme in the designer, it's going to revert to whatever the system/XAML/code results in when you actually run it.
If I remember correctly, you can check in the manifest in the first tab. There should be an option for ya there.
The background color of the page won't be visible, because the root Grid is opaque and have it's color set to black by default, what you can do is set the color of the Grid to a transparent one, or apply the white color to the Grid, as i see you've already applied the color to the Grid, i recommned you to quit the Style properties of the Grid and see if that helps.
I found a different way.
If you click on the grid item in the XAML code, to select it. Then look in the properties window, expand the Brush property and you will see the "Background" item. Click on the small black square to the right of the background property, this will bring up a pop up menu. Click the "Convert to Local value". This will then give you the ability to change the background with the available items underneath. I got mine to be a gradient fill from green to yellow! Ghastly! :-)
I would like to write a C# app that runs like an overlay on the desktop wallpaper. Similar to the way that desktop widgets or Rainmeter(rainmeter.net) runs; behind other apps but on top of the desktop wallpaper.
I cannot find any C# examples of this kind of behavior. Can someone point to me to some code?
Here is an example of what I am interested in creating: http://jabz.us/uploaded_images/screenCaptureRainmeter.png
Why not just use WPF windows that are borderless (and therefore static, but you can move them again by using this code), transparent and below all other windows? You may have to poll each window under the rest every 100ms or so incase the user accidentally clicks it. I have made a little test with just some labels and it looks fine.
For example, use this code and poll the "below all other windows" method every so often.
<Window x:Class="WpfTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="LearnWPF.BorderlessWindow" Height="200" Width="200"
WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True"
Background="Transparent"
>
<Border Padding="5" BorderBrush="#feca00"
BorderThickness="3" Width="150" Height="150">
<TextBlock>Learn WPF!</TextBlock>
</Border>
</Window>