编辑列表中的值(C#UWP)

时间:2016-10-20 06:37:00

标签: c# visual-studio uwp

我为UWP编写应用程序

我像这样下载JSON

 public static Observable<Void> usingProgressDialog(final Context context) {
    return Observable.using(
            () -> {
                ProgressDialog progressDialog = new ProgressDialog(context);
                progressDialog.setMessage(context.getString(R.string.loading));
                progressDialog.setCancelable(false);
                progressDialog.show();
                return progressDialog;
            },
            progressDialog -> Observable.just(null), Dialog::dismiss);
}

之后我将所有数据写入此列表

public async void Inwork_down()
    {

        RestAPI rest = new RestAPI("http://simplegames.com.ua/wp-json/wc/v1/", "ck_9d64c027d2c5f81b8bed3342eeccc6d337be813d", "cs_60697b1e6cbdeb8d62d19e0765e339f8e3334754");
        WCObject wc = new WCObject(rest);
        //Get all products
        var orders = await wc.GetOrders(new Dictionary<string, string>() {
                      { "per_page", "100" }, { "status","processing"} }); // Dodelat filtr dlaya teh chto v  rabote


        string products = orders.ToFormattedJsonString();
        Debug.WriteLine(products);

        List<RootObject> rootObjectData = JsonConvert.DeserializeObject<List<RootObject>>(products);
        OrdersList = new List<RootObject>(rootObjectData);



    }

使用像这样的Bindings显示List中的数据

 private List<RootObject> ordersList;
    public List<RootObject> OrdersList
    {
        get { return ordersList; }
        set { ordersList = value; OnPropertyChanged(); }
    }

当我在xaml中单击ListView中的元素时,它会获取被点击元素的数据并将其绑定到另一个列表视图中的TextBox。

像这样:

 <ListView x:Name="OrderList"  ItemsSource="{Binding OrdersList}"
                  SelectedItem="{Binding OrdersChange, Mode=TwoWay}" IsItemClickEnabled="True" SelectionMode="Single" ItemClick="MyClick"  
                      >
            <ListView.ItemTemplate>
                <DataTemplate>

                    <Grid x:Name="GridInf"   Height="204" BorderBrush="#FFFBF8F8" BorderThickness="0,0,1,1">
                        <TextBlock Text="{Binding date_created}"  HorizontalAlignment="Left" TextAlignment="Center" TextWrapping="Wrap"  VerticalAlignment="Top" Width="350" Height="50" FontFamily="SF UI Display" FontSize="25" FontWeight="Light" Foreground="White" />

和xaml:

private RootObject ordersChange;

    public RootObject OrdersChange
    {
        get { return ordersChange;}
        set { ordersChange = value; OnPropertyChanged(); }
    }

我需要在第二个ListView中更新值并将其写入List。

我怎么能这样做?

0 个答案:

没有答案