Skip to content
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

[Feature] Create XAML helpers for handling provider state #97

Closed
nmetulev opened this issue Apr 21, 2021 · 4 comments
Closed

[Feature] Create XAML helpers for handling provider state #97

nmetulev opened this issue Apr 21, 2021 · 4 comments
Labels
Completed 🔥 enhancement ✨ New feature or request
Milestone

Comments

@nmetulev
Copy link
Contributor

There are few ways we could help developers manage the provider states in XAML

  1. Add a new trigger that will allow developers to set VisualState based on a the current provider state
    <Page>
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup>
                    <VisualState>
                        <VisualState.StateTriggers>
                            <communityToolkit:AuthStateTrigger State="SignedIn" />
                        </VisualState.StateTriggers>
    
                        <VisualState.Setters>
                            <Setter Target="myGrid.Visibility" Value="Visible" />
                        </VisualState.Setters>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid x:Name="myGrid" Visibility="Collapsed">
                ...
            </Grid>
        </Grid>
    </Page>
  2. Add a new extension to help with the most common scenario, setting visibility
    <Grid communityToolkit:VisibleWhenSignedIn="True">
        ....
    </Grid
@ghost ghost added the needs triage 🔍 label Apr 21, 2021
@ghost
Copy link

ghost commented Apr 21, 2021

Hello nmetulev, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

@shweaver-MSFT
Copy link
Member

I attempted to create a ProviderStateTrigger, but I ran into some issues getting it to work. Basically the constructor is never called, and neither are any property setters when the trigger is created in XAML. This makes it impossible to listen for changes in the GlobalProvider and renders the trigger useless.

My attempt lives here:
https://github.com/windows-toolkit/Graph-Controls/blob/shweaver/provider-trigger/CommunityToolkit.Graph.Uwp/Triggers/ProviderStateTrigger.cs

@michael-hawker
Copy link
Member

@shweaver-MSFT NetworkConnectionStateTrigger should be a good trigger to pattern off of. I tested in the sample app that it's working great and detecting a disabled/disconnected internet connection. 🙂

Maybe double-check that the VSM itself is working and is setup proper in the example? I think it can only work at the root element of a page, so it won't work in a nested Grid for instance.

@ghost ghost added the In-PR 🚀 label Jun 1, 2021
@shweaver-MSFT
Copy link
Member

@michael-hawker I got it working :) I was just doing it wrong. Check it out! I baked it right into the SampleTest app as an easy way to test it. #107

@ghost ghost added Completed 🔥 and removed In-PR 🚀 labels Jun 8, 2021
@shweaver-MSFT shweaver-MSFT mentioned this issue Jun 11, 2021
17 tasks
@ghost ghost locked as resolved and limited conversation to collaborators Jul 9, 2021
@shweaver-MSFT shweaver-MSFT added this to the 7.1.0 milestone Aug 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Completed 🔥 enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants