コード例 #1
0
 /// <summary>
 /// Updates viewmodel to reflect the navigation that just occurred
 /// either via Bxf or via the browser navigation buttons or address bar.
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event args</param>
 public void Navigated(object sender, Bxf.Xaml.ExecuteEventArgs e)
 {
   var args = (NavigationEventArgs)e.TriggerParameter;
   var viewName = args.Uri.OriginalString;
   if (string.IsNullOrWhiteSpace(viewName))
     viewName = "Home";
   string queryString = null;
   var param = viewName.IndexOf("?");
   if (param > 0)
   {
     queryString = viewName.Substring(param + 1);
     viewName = viewName.Substring(0, param);
   }
   foreach (var child in this.MenuItems)
   {
     child.SetState(viewName);
     if (args.Content != null && child.Uri == viewName && !string.IsNullOrEmpty(child.ViewModelResourceName) && child.ViewModelType != null)
     {
       object vm;
       if (queryString == null)
         vm = Activator.CreateInstance(child.ViewModelType);
       else
         vm = Activator.CreateInstance(child.ViewModelType, queryString);
       var cvs = (CollectionViewSource)((Control)args.Content).Resources[child.ViewModelResourceName];
       if (vm is IEnumerable)
         cvs.Source = vm;
       else
         cvs.Source = new List<object> { vm };
     }
   }
 }
コード例 #2
0
 protected override void InitializeBindingResource(Bxf.IView view)
 {
   if (view != null && !string.IsNullOrEmpty(view.ViewName) && !view.ViewName.StartsWith("/"))
     base.InitializeBindingResource(view);
   // otherwise do nothing since the view is "lazy loaded" by
   // the navigation engine and the viewmodel is created
   // later
 }
コード例 #3
0
ファイル: MainMenu.cs プロジェクト: Jaans/csla
 public void MenuItemSelected(object sender, Bxf.Xaml.ExecuteEventArgs e)
 {
   var listbox = (ListBox)e.TriggerSource;
   var menuItem = (MenuItem)listbox.SelectedItem;
   if (menuItem.IsAuthorized)
     menuItem.Method();
   else
     Bxf.Shell.Instance.ShowError("You are not authorized to perform this action", "Authorization error");
 }
コード例 #4
0
ファイル: NavigationShell.cs プロジェクト: nschonni/csla-svn
 protected override void InitializeBindingResource(Bxf.IView view)
 {
   PendingView = view;
 }
コード例 #5
0
    /// <summary>
    /// Updates viewmodel to reflect the navigation that just occurred
    /// either via Bxf or via the browser navigation buttons or address bar.
    /// </summary>
    /// <param name="sender">Sender</param>
    /// <param name="e">Event args</param>
    public void Navigated(object sender, Bxf.Xaml.ExecuteEventArgs e)
    {
      var args = (NavigationEventArgs)e.TriggerParameter;
      if (args != null && args.Content != null)
      {
        var viewName = args.Uri.OriginalString;
        if (string.IsNullOrEmpty(viewName))
          viewName = "/MainPage.xaml";
        string queryString = null;
        var param = viewName.IndexOf("?");
        if (param > 0)
        {
          queryString = viewName.Substring(param + 1);
          viewName = viewName.Substring(0, param);
        }

        object viewmodel = null;
        // setup viewmodel for pages
        if (viewName.Contains("/TestPage.xaml"))
          viewmodel = new ViewModels.TestViewModel(queryString);
        ((Control)args.Content).DataContext = viewmodel;
      }
    }
コード例 #6
0
 protected override void InitializeBindingResource(Bxf.IView view)
 {
     // do nothing since the view is "lazy loaded" by
     // the navigation engine and the viewmodel is created
     // later
 }
コード例 #7
0
 /// <summary>
 /// Handle case where navigation has failed by invoking
 /// standard error/exception handling.
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">Event args</param>
 public void NavigationFailed(object sender, Bxf.Xaml.ExecuteEventArgs e)
 {
   var args = (NavigationFailedEventArgs)e.TriggerParameter;
   args.Handled = true;
   Bxf.Shell.Instance.ShowError(string.Format("Page not found: {0}", args.Uri.OriginalString), "Navigation failure");
 }