JavaScript
{ #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame(); var viewModel = new MainWindowModel(); MainPage main = new MainPage(); main.DataContext = viewModel;
// TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; }DataAccess.cs
C#
{ readonly ListMenu> _menu; public MenuRespository() { if(_menu==null) { _menu = new ListMenu>(); } _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); _menu.Add(Menu.CreateMenu("/Photos/Gas-50.png", "t")); } public ListMenu> GetMenu() { return new ListMenu>(_menu); } }Menu.cs
C#
public class Menu { public static Menu CreateMenu(string iconthumb, string text) { return new Menu { IconThumb = iconthumb, Text = text }; } public string IconThumb { get; set; } public string Text { get; set; } }MainWindowsModel
C#
public class MainWindowModel :ViewModelBase { readonly MenuRespository _menuRepository; ObservableCollectionViewModelBase> _viewModels; public MainWindowModel() { _menuRepository = new MenuRespository(); //create an instance of our viewmodel add it to our collection MenuListViewModel viewModel = new MenuListViewModel(_menuRepository); this.ViewModels.Add(viewModel); } public ObservableCollectionViewModelBase> ViewModels { get { if(_viewModels==null) { _viewModels = new ObservableCollectionViewModelBase>(); } return _viewModels; } } }ViewBase
C#
public abstract class ViewModelBase :INotifyPropertyChanged, IDisposable { protected ViewModelBase() { } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler hander = this.PropertyChanged; if(hander!=null) { var e = new PropertyChangedEventArgs(propertyName); hander(this, e); } } public void Dispose() { this.Dispose(); } protected virtual void OnDispose() { } }MenuListBox.xaml into
"
The final
Mainpages.
SelectionChanged="lstMainMenu_SelectionChanged"
Background="Transparent"
ItemsSource="{Binding ViewModels}">
I'm developing on universal..
When debuger is loading then listbox show off "mixnokia.viewmodel.menulistviewmodel "


Akhil GargRank #772 · 3K reputationPosted Apr 9, 2015, 7:07 AM EDT
Lê Hoàng5 reputationPosted Apr 9, 2015, 4:10 PM EDT