ソース掲示板




すべてから検索

キーワード   条件 表示 現行ログ 過去ログ トピックス 名前 本文
Windows8(C#) ストアアプリ MVVM : ListBox テンプレート 用 画面( XAML ) バインド用クラス :
日時: 2013/05/22 22:42
名前: lightbox



ListMain.cs
拡張子:
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LBOX_ListBox
{
	public class ListMain : INotifyPropertyChanged
	{

		// *****************************************************
		// コンストラクタ
		// *****************************************************
		public ListMain()
		{
			// バインド用のコレクションのインスタンスを設定
			this.Items = new ObservableCollection<ListItem2>();
		}

		// *****************************************************
		// バインド用のコレクションのプロパティ
		// ※ ListItem クラスを使用しています
		// *****************************************************
		public ObservableCollection<ListItem2> Items { get; private set; }

		// **********************************************
		// ソースが変更されたことをバインド エンジンに通知する
		// ※ 初回のロードのみならば特に使用しない
		// **********************************************
		public event PropertyChangedEventHandler PropertyChanged;
		public void NotifyPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this,
					new PropertyChangedEventArgs(propertyName));
			}
		}
	}
}
メンテナンス

ListItem2 クラス と 継承された ListItem クラス ( No.1 )
日時: 2013/05/22 22:39
名前: lightbox


日時: 2013/05/22 22:39
名前: lightbox
ListItem.cs
拡張子:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LBOX_ListBox
{
	public class ListItem : INotifyPropertyChanged
	{

		// 番号
		public string id { get; set; }
		// 名前
		public string name { get; set; }

		// **********************************************
		// ソースが変更されたことをバインド エンジンに通知する
		// ※ 初回のロードのみならば特に使用しない
		// **********************************************
		public event PropertyChangedEventHandler PropertyChanged;
		public void NotifyPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
			{
				PropertyChanged(this,
					new PropertyChangedEventArgs(propertyName));
			}
		}

	}
}
ListItem2.cs
拡張子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LBOX_ListBox
{
	public class ListItem2 : ListItem
	{
		// 名前
		private string _name;
		new public string name
		{
			get
			{
				return _name;
			}
			set
			{
				_name = value;
				this.NotifyPropertyChanged("name");
			}
		}
	}
}
このアーティクルの参照用URLをクリップボードにコピー メンテナンス