1.问题:
根据业务场景我使用了ItemControl嵌套组合,外层的数据已经绑定到了,但是内层的没有绑上。
2.代码:
public class DishMenuViewModel : Command.NoticeCommand
{
private ObservableCollection<Test> originalList = new ObservableCollection<Test>();
public ObservableCollection<Test> OriginalList
{
get { return originalList; }
set { originalList = value; }
}
public class Test
{
public string TypeName { get; set; }
public ObservableCollection<TestChild> TestChilds { get; set; }
}
public class TestChild
{
public double Number { get; set; }
public string Diet_dish_name { get; set; }
public int Amount { get; set; }
public string TypeName { get; set; }
}
public DishMenuViewModel()
{
var data = new Test();
var data1 = new TestChild()
{
Diet_dish_name = "测试",
Number = 3,
Amount = 2,
TypeName = "大类1"
};
var data2 = new TestChild()
{
Diet_dish_name = "测试",
Number = 3,
Amount = 2,
TypeName = "大类1"
};
var data3 = new TestChild()
{
Diet_dish_name = "测试",
Number = 3,
Amount = 2,
TypeName = "大类1"
};
var data4 = new TestChild()
{
Diet_dish_name = "测试",
Number = 3,
Amount = 2,
TypeName = "大类1"
};
data.TestChilds = new ObservableCollection<TestChild>();
data.TestChilds.Add(data1);
data.TestChilds.Add(data2);
data.TestChilds.Add(data3);
data.TestChilds.Add(data4);
data.TypeName = "大类1";
OriginalList.Add(data);
}
}
3.尝试过换父级资源 但是已然绑定不到,希望得到帮助,x'x