-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Announcing: WinUI 3 in Windows App SDK 1.1 Preview 3 ✨ #7061
Comments
Just hit an Access Violation with |
Yup still hitting issue with the latest, details here: #7062 |
Why I use Nuget package to update WindowsAppSDK to 1.1.0 preview version 3 still can't use Background Acrylic in C++ desktop development |
Seeing an issue in our CI with the 1.1.0-preview3 package (that I didn't see with 1.0.0, testing 1.0.3 now):
Is this because it's a preview package or an issue that's regressed? |
How do I actually use Mica? The property "BackdropMaterial.ApplyToRootOrPageBackground" does still not exist in WinAppSDK 1.1 prev3 I want to change the theme at runtime, so I came up with the following adjustment: SystemBackdropWindow.csusing Microsoft.UI;
using Microsoft.UI.Composition;
using Microsoft.UI.Composition.SystemBackdrops;
using Microsoft.UI.Xaml;
using System.Runtime.InteropServices;
using WinRT;
namespace YOURNAMESPACEGOESHERE
{
public class SystemBackdropWindow : Window
{
public ApplicationTheme ActualTheme = ApplicationTheme.Dark;
ElementTheme requestedTheme = ElementTheme.Default;
public ElementTheme RequestedTheme
{
get => requestedTheme;
set
{
requestedTheme = value;
switch (value)
{
case ElementTheme.Dark: ActualTheme = ApplicationTheme.Dark; break;
case ElementTheme.Light: ActualTheme = ApplicationTheme.Light; break;
case ElementTheme.Default:
var uiSettings = new Windows.UI.ViewManagement.UISettings();
var defaultthemecolor = uiSettings.GetColorValue(Windows.UI.ViewManagement.UIColorType.Background);
ActualTheme = defaultthemecolor == Colors.Black ? ApplicationTheme.Dark : ApplicationTheme.Light;
break;
}
}
}
public SystemBackdropWindow()
{
RequestedTheme = App.Current.RequestedTheme == ApplicationTheme.Dark ? ElementTheme.Dark : ElementTheme.Light;
m_wsdqHelper = new WindowsSystemDispatcherQueueHelper();
m_wsdqHelper.EnsureWindowsSystemDispatcherQueueController();
SetBackdrop(BackdropType.Mica);
}
public enum BackdropType
{
Mica,
DesktopAcrylic,
DefaultColor,
}
WindowsSystemDispatcherQueueHelper m_wsdqHelper;
BackdropType m_currentBackdrop;
MicaController m_micaController;
DesktopAcrylicController m_acrylicController;
SystemBackdropConfiguration m_configurationSource;
public void SetBackdrop(BackdropType type)
{
m_currentBackdrop = BackdropType.DefaultColor;
if (m_micaController != null)
{
m_micaController.Dispose();
m_micaController = null;
}
if (m_acrylicController != null)
{
m_acrylicController.Dispose();
m_acrylicController = null;
}
this.Activated -= Window_Activated;
this.Closed -= Window_Closed;
m_configurationSource = null;
if (type == BackdropType.Mica)
{
if (TrySetMicaBackdrop())
{
m_currentBackdrop = type;
}
else
{
type = BackdropType.DesktopAcrylic;
}
}
if (type == BackdropType.DesktopAcrylic)
{
if (TrySetAcrylicBackdrop())
{
m_currentBackdrop = type;
}
else
{
}
}
}
bool TrySetMicaBackdrop()
{
if (MicaController.IsSupported())
{
m_configurationSource = new SystemBackdropConfiguration();
this.Activated += Window_Activated;
this.Closed += Window_Closed;
m_configurationSource.IsInputActive = true;
switch (RequestedTheme)
{
case ElementTheme.Dark: m_configurationSource.Theme = SystemBackdropTheme.Dark; break;
case ElementTheme.Light: m_configurationSource.Theme = SystemBackdropTheme.Light; break;
case ElementTheme.Default: m_configurationSource.Theme = SystemBackdropTheme.Default; break;
}
m_micaController = new MicaController();
m_micaController.AddSystemBackdropTarget(this.As<ICompositionSupportsSystemBackdrop>());
m_micaController.SetSystemBackdropConfiguration(m_configurationSource);
return true;
}
return false;
}
bool TrySetAcrylicBackdrop()
{
if (DesktopAcrylicController.IsSupported())
{
m_configurationSource = new SystemBackdropConfiguration();
this.Activated += Window_Activated;
this.Closed += Window_Closed;
m_configurationSource.IsInputActive = true;
switch (RequestedTheme)
{
case ElementTheme.Dark: m_configurationSource.Theme = SystemBackdropTheme.Dark; break;
case ElementTheme.Light: m_configurationSource.Theme = SystemBackdropTheme.Light; break;
case ElementTheme.Default: m_configurationSource.Theme = SystemBackdropTheme.Default; break;
}
m_acrylicController = new DesktopAcrylicController();
m_acrylicController.AddSystemBackdropTarget(this.As<ICompositionSupportsSystemBackdrop>());
m_acrylicController.SetSystemBackdropConfiguration(m_configurationSource);
return true;
}
return false;
}
private void Window_Activated(object sender, WindowActivatedEventArgs args)
{
m_configurationSource.IsInputActive = args.WindowActivationState != WindowActivationState.Deactivated;
}
private void Window_Closed(object sender, WindowEventArgs args)
{
if (m_micaController != null)
{
m_micaController.Dispose();
m_micaController = null;
}
if (m_acrylicController != null)
{
m_acrylicController.Dispose();
m_acrylicController = null;
}
this.Activated -= Window_Activated;
m_configurationSource = null;
}
}
class WindowsSystemDispatcherQueueHelper
{
[StructLayout(LayoutKind.Sequential)]
struct DispatcherQueueOptions
{
internal int dwSize;
internal int threadType;
internal int apartmentType;
}
[DllImport("CoreMessaging.dll")]
private static extern int CreateDispatcherQueueController([In] DispatcherQueueOptions options, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object dispatcherQueueController);
object m_dispatcherQueueController = null;
public void EnsureWindowsSystemDispatcherQueueController()
{
if (Windows.System.DispatcherQueue.GetForCurrentThread() != null)
{
return;
}
if (m_dispatcherQueueController == null)
{
DispatcherQueueOptions options;
options.dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions));
options.threadType = 2;
options.apartmentType = 2;
CreateDispatcherQueueController(options, ref m_dispatcherQueueController);
}
}
}
} MainPage.xaml.cspublic sealed partial class MainPage : Page
{
ViewModel VM = App.VM;
public MainPage()
{
this.InitializeComponent();
}
private void Cbx_Theme_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Update your SystemBackdropWindow to use the new Theme (here, Cbx_Theme.SelectedItem is bound to ViewModel.RequestedTheme):
App.MainWindow.RequestedTheme = VM.RequestedTheme;
App.MainWindow.SetBackdrop(VM.RequestedBackdrop);
// Your TitleBarCustomization stuff goes here:
if (App.IsWin11)
{
App.AppWindow.TitleBar.ButtonForegroundColor = App.MainWindow.ActualTheme == ApplicationTheme.Dark ? Colors.White : Colors.Black;
}
}
private void Cbx_Backdrop_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Update your SystemBackdropWindow to use the new Backdrop (here, Cbx_Backdrop.SelectedItem is bound to ViewModel.RequestedBackdrop):
App.MainWindow.SetBackdrop(VM.RequestedBackdrop);
}
} But all of this is so complicated! Will there ever be a "BackdropMaterial.ApplyToRootOrPageBackground" implementation in WinAppSDK for Desktop? |
It seems that their implementation at this stage will be more complicated than the original version. The official roadmap says that version 1.2 will try to simplify it. |
Will background acrylic be supported on Windows 10? |
Can this issue please get addressed - #4804 - surely it's a simple fix, crashing the app when the user right clicks a textbox is absolutely terrible |
1.1 Preview 3 Release of Windows App SDK
Earlier this week we released our third preview of the 1.1 release of the Windows App SDK! This preview includes new features and bug fixes for WinUI 3 apps, including:
To see everything that's new and changed, see the full release notes here.
What's next
To keep up with progress being made on the Windows App SDK, please see our feature roadmap, which gets updated regularly.
Providing feedback
As we introduce new & upcoming features in our preview releases, we appreciate all of your feedback as we work towards a stable release:
The text was updated successfully, but these errors were encountered: