There is an interface:
public interface IAccount { IList<AccountViewModel> GetAccountList(); } Here for a designtime I implement it:
public class DesignAccountManagerViewModel: IAccount { public IList<AccountViewModel> GetAccountList() { var people = new List<AccountViewModel> { new AccountViewModel("", "", new VkAccount( new Uri( "http://images5.fanpop.com/image/photos/25900000/Poke-icons-pokemon-25942511-100-100.jpg"), "Пикачу")), new AccountViewModel("", "", new VkAccount( new Uri( "http://vignette2.wikia.nocookie.net/pokemon/images/3/39/007Squirtle.png/revision/latest/scale-to-width-down/100?cb=20140328191525"), "Сквирел")) }; return people; } } Here for runtime:
public IList<AccountViewModel> GetAccountList() { return new ObservableCollection<AccountViewModel>(); ///Здесь будет еще загрузка из сохраненных данных } Constructor:
public AccountManagerViewModel(IAccount dataService) { AccountList = new ObservableCollection<AccountViewModel>(); var al = dataService.GetAccountList(); //Это я уже как не извращался foreach (var a in al) { AccountList.Add(a); } } I register in ViewModelLocator :
if (ViewModelBase.IsInDesignModeStatic) { SimpleIoc.Default.Register<IAccount, DesignAccountManagerViewModel>(); } else { SimpleIoc.Default.Register<IAccount, AccountList>(); } SimpleIoc.Default.Register<AccountManagerViewModel>(); I register in xaml :
<cntr:AccountManagerControl DataContext="{Binding Source={StaticResource Locator}, Path=AccountManager}" Grid.Row="1" Grid.RowSpan="2"/> In runtime, everything works; in the designer, FIG. Chyadt?
DesignAccountManagerVM? Let's try to limit the list of possible problems. - VladD