JOSN數據可以通過使用JSON.Net和JSONORM進行管理。您可以通過jsonorm
得到它的NuGet XAML中獲取數據使用的數據模板後。這是一個例子。創建一個窗口並粘貼這個XAML。
<Window x:Class="DataTemplate.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="myTaskTemplate">
<Grid Height="115" Width="456">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="5" Foreground="#FF0079C3" FontSize="15" FontFamily="Segoe UI Semilight" IsHyphenationEnabled="True"
LineStackingStrategy="BlockLineHeight" TextAlignment="Left" TextWrapping="Wrap" Text="{Binding task_id}"/>
<TextBlock Grid.Row="1" Grid.Column="0" Foreground="#FF7F7F7F" FontSize="12" FontFamily="Segoe UI Semilight"
IsHyphenationEnabled="True" LineStackingStrategy="BlockLineHeight" Text="{Binding alert}" TextAlignment="Left"/>
<TextBlock Grid.Row="2" Grid.Column="0" Foreground="#FF7F7F7F" FontSize="12" FontFamily="Segoe UI Semilight"
IsHyphenationEnabled="True" LineStackingStrategy="BlockLineHeight" Text="{Binding task_description}" TextAlignment="Left"/>
<Path Grid.Row="3" Grid.Column="0" Data="F1M8,2C11.314,2 14,4.686 14,8 14,11.313 11.314,14 8,14 4.686,14 2,11.313 2,8 2,4.686 4.686,2 8,2z"
Fill="#FF85F088" HorizontalAlignment="Right" Grid.RowSpan="1"
Stretch="Uniform"/>
<Path Grid.Row="3" Grid.Column="0" Data="F1M8,2C11.314,2 14,4.686 14,8 14,11.313 11.314,14 8,14 4.686,14 2,11.313 2,8 2,4.686 4.686,2 8,2z"
Fill="#FF85F088" HorizontalAlignment="Right" Grid.RowSpan="1"
Stretch="Uniform" RenderTransformOrigin="-1.087,0.548" Margin="0,1,31,-1"/>
<Path Grid.Row="3" Grid.Column="0" Data="F1M8,2C11.314,2 14,4.686 14,8 14,11.313 11.314,14 8,14 4.686,14 2,11.313 2,8 2,4.686 4.686,2 8,2z"
Fill="#FF85F088" HorizontalAlignment="Right" Grid.RowSpan="1"
Stretch="Uniform" RenderTransformOrigin="-1.087,0.548" Margin="0,0,63,0"/>
</Grid>
</DataTemplate>
</Window.Resources>
<ListBox Grid.Column="0" Grid.Row="1"
ItemsSource="{Binding Followers,IsAsync=True}"
ItemTemplate="{StaticResource myTaskTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
HorizontalContentAlignment="Stretch" Margin="0,13,0,0"/>
<!---->
<!--"" -->
按照DataContext的
using System.Text;
using System.Threading.Tasks;
using InSync.appseconnect.Helper;
using ObjectDAL;
using jsonorm;
public class DataContext : ObservableObjectGeneric<DataContext>
{
private List<Task_details> _taskdetaillist;
public DataContext()
{
Followers = new Task_details().GetElementList("Task_details");
}
public List<Task_details> Followers
{
get
{
return _taskdetaillist;
}
set
{
_taskdetaillist = value;
OnPropertyChanged("Followers");
}
}
}
以下是ObjectDAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using jsonorm;
namespace ObjectDAL
{
public class Comment
{
public string task_comment_id { get; set; }
public string f_id { get; set; }
public string comment { get; set; }
public string created_date { get; set; }
public string updated_date { get; set; }
}
public class Follower
{
public string f_id { get; set; }
}
public class Task_details : LocalStorage<Task_details>
{
public string task_id { get; set; }
public string created_f_id { get; set; }
public string task_description { get; set; }
public string due_date { get; set; }
public string alert { get; set; }
public string status { get; set; }
public string postedon { get; set; }
public string updatedon { get; set; }
public List<Comment> comments { get; set; }
public List<Follower> followers { get; set; }
}
public class TaskDetailList : LocalStorage<TaskDetailList>
{
public int status { get; set; }
public string message { get; set; }
public List<Task_details> Task_details { get; set; }
}
}
是的,但我需要的代碼,因爲進出口新的發展的WP8到,面對綁定的概率關注列表圖片在Xaml – Srirama