私はviewModelとして機能する1つのテーブルを持っています。これから、私の見解では私の縛りの源になっているはずです。私の目的は、このテーブル/ビューモデルを2つの他のテーブルに基づいて更新することです。私はviewModelのviewViewModelで設定されるテーブルchecklistTableとAnswerTableのそれぞれから1つのプロパティを持っています。テーブルの値を他のテーブルの値と同じに設定する
現時点では、それぞれのテーブルから必要な現在の要素をクエリしており、viewModelを更新しようとしています。
分離コード:
//Curent descriptions to be set in the viewModel
var currentDescription = (_check.Where(s => currentElements.Contains(s.defineId)).Select(s=> s.Description).ToList());
//Current colors to be set in the viewModel
var currentColors = (from current in _answer
where current.questionId == currentCheckId &&
current.buildingId == currentBuildingId
orderby current.dateReported descending
select current.backgroundColor).ToList();
theese値を取得した後、私は私のViewModelを更新しようと、物事がうまくいかない場所です:
for (int i =0 ; i < currentDescription.Count() - 1; i++)
{
currentViewTable.Description = currentDescription[i];
}
for (int i =0 ; i < currentColors.Count() - 1; i++)
{
currentViewTable.backgroundColor.Insert(i,currentColors[i]);
}
私はエラーを取得する:参照がに設定されていませんオブジェクトのインスタンス。私のviewModel、または私が間違っていることに関するヒントを更新するためのより良い方法がありますか?
詳細をご記入ください:「私は、ビューモデルとして機能するテーブルを1つ持っています。」 いくつかのxamlを表示してください。 currentViewTableは何ですか? – Mishka