microsoft / XboxGameBarSamples

Sample code for Xbox Game Bar Widgets
https://developer.microsoft.com/games/products/game-bar/
MIT License
145 stars 27 forks source link

[Question] Widget settings's guide/documentation for Multi-View Communication or Feature to make it easier #84

Open edwardchanjw opened 3 years ago

edwardchanjw commented 3 years ago

Is your feature request related to a problem? Please describe. UWP Multi-View Communication, I am trying the second method of this article. I cant seem to make it worked. First method, I am no sure I know how to make it worked. Remaining option is static variable in App.xaml, which would be the last thing I would do, except redux store of course.

Describe the solution you'd like My use case could be automatic update the widget1, while Widget Settings changed. For example, manually change the custom user-configurable option in setting widget then the widget1(note) can automatic change formatting (For example, for text widget or code mode.)

Describe alternatives you've considered No yet, Knowledge on UWP have no enough to find alternatives for now. To be frankly, I am also not a fan of MVVM. I feel way more trouble to implement reactive and real time feature than Web. But some obstacle and less documentation if the stability and efficiency is the reward.

  1. sender.ActivateSettingsAsync(this); able to passing like first method of UWP Multi-View Communication

  2. rootFrame.Navigate(typeof(WidgetSettings), widget2); Manually manage windows, Weird and messy, cant use on widget.SettingsClicked += Widget_SettingsClicked;

  3. Use settingsClicked button to show other widget like widget1 as setting widget for widget2. But following might cause exception

    private async void Widget_SettingsClicked(XboxGameBarWidget sender, object args){
         widget1 = new XboxGameBarWidget(widgetArgs,Window.Current.CoreWindow,rootFrame);
    }
vidager commented 3 years ago

Hi edwardchanjw,

For 3rd party widgets created through our SDK, we only support a single CoreWindow per widget identity specified in your manifest. So you can have X widgets ("views") for your app, but they each need to be independently activated by Game Bar. This must be done so we can bind the CoreWindow from your process to the XAML tree inside our ViewChrome (the Window that holds your content). XAML has some tricks where content can span outside that space, such as flyouts, but otherwise the content is constrained to your CoreWindow inside the Game Bar View Chrome.

When you get an activation for each of your widgets, you can pass a context to them (for example through page navigation if you use that). That context can be shared data that both widgets observe. This is how many widgets handle their settings, where the settings are in Widget B for the main Widget A. Our samples show how you can activate multiple widgets, including a settings widget from our settings icon, but we don't really have guidance on widget to widget communication (within the same app) as you can use your favorite method (MVVM with shared data model, or otherwise).

If you look at our settings sample, you will see how to perform the whole activation flow piece (from the settings button). If you look at our advanced sample(s), you'll see how to activate Widget B from Widget A.

Thanks, Ben

edwardchanjw commented 3 years ago

Not an important feature, Currently GameBar already provided a lot of useful feature.

For example, just one some easy mechanism like setting Dark/White mode in widget settings will update the widget immediately.

More likely a syntactic sugar feature request after product launch and if developer's market flourish, treat my issue as just documenting the method of Multi-view communication