MVVM Silverlight - can not assign existing control to a property of collection of custom elements in XAML
I have a class
public class Item { public string A { get; set; } public Control B { get; set; } }
I'm using MVVM with Silverlight. I have a custom view that is inherited from a standard view开发者_如何学Go. Custom view has public property
public ICollection MyItems { get; set; }which should store items described above.
In xaml of my view I have
xxxx.MyItems> Item A="someText" B="_existingButton" /> Item A="someText2" B="_existingButton2" /> /xxxx.MyItems>
Initialize() method of View fails when trying to assign value for B.
How can I assign a reference to existing element for a custom collection item?
I don't exactly understand what you are trying to achieve, but to help you arrive at a solution, I recommend that you attempt your task in the code behind file first (i.e. in the .xaml.cs) file.
By doing this, you will be given much more informative help from the compiler and intellisense.
Once you've achieved what you wanted in the code behind, then try and implement it in the xaml file.
精彩评论