예제 #1
0
        public void SetViewContext(IViewContext viewContext, ViewInfo viewInfo)
        {
            ViewLayout viewLayout = null;

            if (null != viewInfo && viewContext != null && viewInfo.ViewGroup != null)
            {
                var viewLayoutList = viewContext.GetViewLayoutList(viewInfo.ViewGroup.Id.ViewName(viewInfo.Name));
                if (null != viewLayoutList)
                {
                    viewLayout = viewLayoutList.FindLayout(viewLayoutList.DefaultLayoutName);
                }
            }
            SetViewContext(viewContext, viewInfo, viewLayout);
        }
예제 #2
0
 public void SetViewContext(IViewContext viewContext, ViewInfo viewInfo)
 {
     ViewContext = viewContext;
     if (null == viewInfo)
     {
         BindingListView.ViewInfo = null;
     }
     else
     {
         IRowSource rowSource   = null;
         bool       viewChanged = true;
         if (null != ViewInfo)
         {
             if (ViewInfo.RowSourceName == viewInfo.RowSourceName)
             {
                 rowSource = RowSource;
                 if (ViewInfo.Name == viewInfo.Name)
                 {
                     viewChanged = false;
                 }
             }
         }
         rowSource = rowSource ?? viewContext.GetRowSource(viewInfo);
         BindingListView.SetViewAndRows(viewInfo, rowSource);
         if (viewChanged)
         {
             BindingListView.ClearTransformStack();
         }
         if (ViewContext != null && viewInfo.ViewGroup != null)
         {
             var viewLayoutList = ViewContext.GetViewLayoutList(viewInfo.ViewGroup.Id.ViewName(viewInfo.Name));
             if (null != viewLayoutList)
             {
                 var defaultLayout = viewLayoutList.FindLayout(viewLayoutList.DefaultLayoutName);
                 if (defaultLayout != null)
                 {
                     ApplyLayout(defaultLayout);
                 }
             }
         }
     }
     OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
 }