Xamarin形成可绑定网格 [英] Xamarin Forms Bindable Grid

查看:130
本文介绍了Xamarin形成可绑定网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Xamarin Forms应用程序上工作,需要能够绑定到Grid.我碰到了这篇文章:

https://www.linkedin.com/pulse/bindable-grid-xamarin-forms-jonas-frid

GitHub上的来源:

https://github.com/Manne990/XamTest/blob/master/XamTest/Views/TemplatedTableView/TemplatedTableView.cs

这正是我所需要的,但是它不响应集合中的更改.我正在使用MvvmHelpers,它对所有ListView都适用:

https://github.com/jamesmontemagno/mvvm-helpers

我假设我需要更新TemplatedTableView.cs以响应CollectionChanged事件-我只是不确定如何执行此操作?

解决方案

您可以尝试 Syncfusion

在XAML中使用

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DataGridDemo;assembly=DataGridDemo"
             xmlns:syncfusion="clr-namespace:Syncfusion.SfDataGrid.XForms;assembly=Syncfusion.SfDataGrid.XForms" 
             x:Class="DataGridDemo.Sample">

    <ContentPage.BindingContext>
        <local:OrderInfoRepository x:Name="viewModel" />
    </ContentPage.BindingContext>

    <ContentPage.Content>
        <syncfusion:SfDataGrid x:Name="dataGrid"
                               ItemsSource="{Binding OrderInfoCollection}">
        </syncfusion:SfDataGrid>
    </ContentPage.Content>
</ContentPage>

请确保在绑定集合更新后调用属性更改事件

它具有很多简洁的功能.

I;m working on a Xamarin Forms application and need to be able to bind to a Grid. I came across this article:

https://www.linkedin.com/pulse/bindable-grid-xamarin-forms-jonas-frid

Source on GitHub:

https://github.com/Manne990/XamTest/blob/master/XamTest/Views/TemplatedTableView/TemplatedTableView.cs

This is exactly what I need, however it doesn't respond to changes in the collection. I'm using MvvmHelpers which works well for all of the ListView's:

https://github.com/jamesmontemagno/mvvm-helpers

I assume I need to update TemplatedTableView.cs to respond to a CollectionChanged event - I'm just not sure how to do this?

解决方案

You can try the grid provided by Syncfusion

Use in XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:DataGridDemo;assembly=DataGridDemo"
             xmlns:syncfusion="clr-namespace:Syncfusion.SfDataGrid.XForms;assembly=Syncfusion.SfDataGrid.XForms" 
             x:Class="DataGridDemo.Sample">

    <ContentPage.BindingContext>
        <local:OrderInfoRepository x:Name="viewModel" />
    </ContentPage.BindingContext>

    <ContentPage.Content>
        <syncfusion:SfDataGrid x:Name="dataGrid"
                               ItemsSource="{Binding OrderInfoCollection}">
        </syncfusion:SfDataGrid>
    </ContentPage.Content>
</ContentPage>

Be sure to call the property changed event after bound collection is updated

It has alot of neat features.

这篇关于Xamarin形成可绑定网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆