How to use the VisualStateManager from winrt/C++ ? #9727
-
I'm new to WinUI 3 and as a hobbyist C/C++ developer (with enough years of Win32 UI coding experience) I want to give this is try. However, moving to WinUI3 is a huge learning curve (at least for me). It doesn't help that most of the documentation and samples are aimed towards C#. But I'm still making good progress, a bit slow at times. What I'm currently trying to do is using the VisualStateManager to do a simple transition of my custom TitleBar text when the main window activates / deactivates. Eventually I want to use this to have a gray-scale icon image when the window is deactivated (I feel this is more in line with the caption text and buttons also using a gray color). My XAML window looks like this:
In the MainWindow.xaml.cpp file I have an Activated event handler like this:
But when running the code I'm getting COM errors about the interface not being supported. The C# samples use "this". Some of the very rare C++ samples use "*this" But I'm getting compile errors as no user defined conversion to winrt::Microsoft::UI::Xaml::Controls::Control exist. What is the supposed way to call the GoToState method ? I've tried many different things but none seem to work. I guess it should be something simple but I can't figure it out. Any help is much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Grid does not inherit from Microsoft::UI::Xaml::Controls::Control
|
Beta Was this translation helpful? Give feedback.
Grid does not inherit from Microsoft::UI::Xaml::Controls::Control
https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.grid?view=windows-app-sdk-1.5
example: