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

WeatherApp Samples with C# Markup and outside refresh #2578

Open
4 tasks
kni opened this issue Sep 30, 2024 · 0 comments
Open
4 tasks

WeatherApp Samples with C# Markup and outside refresh #2578

kni opened this issue Sep 30, 2024 · 0 comments
Labels
kind/contributor-experience Categorizes issue or PR as related to improving the experience of contributors kind/documentation Categorizes an issue or PR as relevant to 3rd party dependencies that are consumed by this project triage/untriaged Indicates an issue requires triaging or verification.

Comments

@kni
Copy link

kni commented Sep 30, 2024

What would you like to be added:

https://github.com/unoplatform/Uno.Samples/tree/master/UI/MvuxHowTos/WeatherApp/WeatherApp

I made a WeatherApp variant with C# Markup.
But I have a question.
I can add a Refresh Button outside FeedView with XAML. It is worked.

    <Grid utu:SafeArea.Insets="Bottom,Top">
        <mvux:FeedView x:Name="feedView" Source="{Binding CurrentWeather}">
            <DataTemplate>
                <StackPanel>
                <TextBlock DataContext="{Binding Data}" Text="{Binding Temperature}" />
                <Button Content="Refresh" Command="{Binding Refresh}" />
                </StackPanel>
            </DataTemplate>
            <mvux:FeedView.ProgressTemplate>
                <DataTemplate>
                <TextBlock Text="Requesting temperature..."/>
                </DataTemplate>
            </mvux:FeedView.ProgressTemplate>
        </mvux:FeedView>
        <Button Content="Refresh outside" Command="{Binding Refresh, ElementName=feedView}" />
    </Grid>
</Page>

But with C# Markup it is NOT worked.
What am I doing wrong?

public sealed partial class MainPage : Page {

    public MainPage() {

        this.DataContext = new BindableWeatherModel(new WeatherService());

        this.DataContext<BindableWeatherModel>((page, vm) => page
            .Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
            .Content(
                new StackPanel()
                    .VerticalAlignment(VerticalAlignment.Center)
                    .HorizontalAlignment(HorizontalAlignment.Center)
                    .Children(
                        new TextBlock()
                            .Text("Hello Uno Platform!"),
                        new FeedView()
                            .Name(out var WeatherFeed)
                            .Source(() => vm.CurrentWeather)

                            .ProgressTemplate(() =>
                                new StackPanel().Children(
                                    new TextBlock().Text("Requesting temperature...")
                                )
                            )

                            .ValueTemplate<FeedViewState>(feedViewState =>
                                new StackPanel().Children(
                                    new TextBlock().Text(() => (WeatherInfo)feedViewState.Data!, w => $"Temperature: {w.Temperature}"),
                                    new Button()
                                       .Margin(10)
                                       .Content("Refresh")
                                       .Command(() => WeatherFeed.Refresh)
                                       // or .Command(() => feedViewState.Refresh)
                                )
                            ),
                        new Button()
                            .Margin(10)
                            .Content("Refresh outside")
                            .Command(() => WeatherFeed.Refresh)
                           
                    )
            )
        );
    }
}

Why is this needed:

There are few examples of C# Markup

For which Platform:

  • iOS
  • Android
  • WebAssembly
  • WebAssembly Renderers for Xamarin.Forms
  • [x ] Windows

Anything else we need to know?

@kni kni added kind/contributor-experience Categorizes issue or PR as related to improving the experience of contributors kind/documentation Categorizes an issue or PR as relevant to 3rd party dependencies that are consumed by this project triage/untriaged Indicates an issue requires triaging or verification. labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/contributor-experience Categorizes issue or PR as related to improving the experience of contributors kind/documentation Categorizes an issue or PR as relevant to 3rd party dependencies that are consumed by this project triage/untriaged Indicates an issue requires triaging or verification.
Projects
None yet
Development

No branches or pull requests

1 participant