0
我正在使用WindowsStore GridApp模板在VS2012 c#/ xaml中創建Windows應用商店應用。 而我正在使用此模板具有的組和項目頁面。在Windows Store應用程序中將DataItems從一個頁面添加到另一個頁面?
在組頁面,我顯示房間列表 - 這個數據源是RoomObjects
public class RoomsObject : LivingDataCommon
{
public RoomsObject()
: base(String.Empty, String.Empty)
{
}
public RoomsObject(String ID, String title)
: base(ID, title)
{ }
//adds Actors to collection of a Room, will be used for Rooms pages
private ObservableCollection<ActorsObject> _actors = new ObservableCollection<ActorsObject>();
public ObservableCollection<ActorsObject> Actors
{
get { return this._actors; }
}
}
在項目網頁,我展示演員的列表,每個房間都有 - 數據源這是ActorsObjects
public class ActorsObject : LivingDataCommon
{
public ActorsObject()
: base(String.Empty, String.Empty)
{
}
public ActorsObject(String ID, String title, Boolean homepage,String function, RoomsObject room, double currentValue, ActorsType type, AllActors allactors)
: base(ID, title)
{
this._function = function;
this._room = room;
this._currentValue = currentValue;
this._type = type;
this._homepage = homepage;
this._all = allactors;
}
//set home page appearance
private Boolean _homepage = false;
public static Boolean Homepage = false;
//sets value of an actor
private double _currentValue;
public double CurrentValue
{
get { return this._currentValue; }
set { this.SetProperty(ref this._currentValue, value); }
}
//sets and gets function code
private string _function = string.Empty;
public string Function
{
get { return this._function; }
set { this.SetProperty(ref this._function, value); }
}
//gets room properity
private RoomsObject _room;
public RoomsObject Room
{
get { return this._room; }
set { this.SetProperty(ref this._room, value); }
}
private ActorsType _type;
public ActorsType Type
{
get { return this._type; }
set { this.SetProperty(ref this._type, value); }
}
private AllActors _all;
public AllActors All
{
get { return this._all; }
set { this.SetProperty(ref this._all, value); }
}
}
當我在項目頁面中選擇一個Actor時,我的appbar出現,我需要在我的pinButton上允許該Actor在Home.xaml中顯示。
我假設我應該創建一個空的ObservableCollection一個選定的項目添加到它,然後使用該集合作爲Home.xaml數據源,但我在新的C#,我不能讓它工作..
請任何建議,代碼或一些不同的方式來做到這一點?
你可以幫我一些代碼,我不是很好的C#? – zarko
我使用這個類 '公共類AllActors:LivingDataCommon { 公共AllActors() :基座(的String.Empty,的String.Empty) { } 公共AllActors(字符串ID,字符串標題) : (ID,標題) {} private ObservableCollection _AllActors = new ObservableCollection (); public ObservableCollection allActors { get {return this._AllActors; }} }' –
zarko
,這是我的按鈕的代碼,但它不添加任何東西 '私人無效Button_Tapped_1(對象發件人,TappedRoutedEventArgs E) { AllActors M =新AllActors(); m.allActors.Add((ActorsObject)itemGridView.SelectedItem); }' – zarko