Hi Telerick,
I am testing telerik for PRISM + Unity.
All of control is beyond my expectation and working great.
However, I experienced one major issue when using RegionManager.RequestNavigate after closing RadPane.
When caller navigates with bookId, there is no issue when the book id is new. The new view is created and activated well.
But I met two issue when the book id exits on list of view.
First, The existing view is not activated after RegionManager.RequestNavigate
Second, I closed the one book view and called RegionManager.RequestNavigate with the book id. In this time, Not thing happens.
The old view looks like alive in the view list....
I am using RadPaneGroupRegionAdapter which comes from your blog
And I tried to DockingExtension on forum but showing same issues.
I spend almost two weeks in order solve this issue but I can't get any clue...
1. ------------- caller ---------------
query.Add("BookId", book.Id.ToString());
RegionManager.RequestNavigate( RegionName.MainContent, new Uri("BookView" + query.ToString(), UriKind.Relative), NavigationComplted);
2. ------- BookViewModel
public bool IsNavigationTarget(NavigationContext navigationContext)
{
UriQuery query = navigationContext.Parameters;
int bookId = Convert.ToInt32(query["BookId"]);
if (this.BookId == bookId)
return true;
return false;
}
3. --- RegionAdapter comes from your blog
4. -- Docking Extension
I am testing telerik for PRISM + Unity.
All of control is beyond my expectation and working great.
However, I experienced one major issue when using RegionManager.RequestNavigate after closing RadPane.
When caller navigates with bookId, there is no issue when the book id is new. The new view is created and activated well.
But I met two issue when the book id exits on list of view.
First, The existing view is not activated after RegionManager.RequestNavigate
Second, I closed the one book view and called RegionManager.RequestNavigate with the book id. In this time, Not thing happens.
The old view looks like alive in the view list....
I am using RadPaneGroupRegionAdapter which comes from your blog
And I tried to DockingExtension on forum but showing same issues.
I spend almost two weeks in order solve this issue but I can't get any clue...
1. ------------- caller ---------------
query.Add("BookId", book.Id.ToString());
RegionManager.RequestNavigate( RegionName.MainContent, new Uri("BookView" + query.ToString(), UriKind.Relative), NavigationComplted);
2. ------- BookViewModel
public bool IsNavigationTarget(NavigationContext navigationContext)
{
UriQuery query = navigationContext.Parameters;
int bookId = Convert.ToInt32(query["BookId"]);
if (this.BookId == bookId)
return true;
return false;
}
3. --- RegionAdapter comes from your blog
public class RadPaneGroupRegionAdapter : RegionAdapterBase<RadPaneGroup> { public RadPaneGroupRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory) { } protected override void AttachBehaviors(IRegion region, RadPaneGroup regionTarget) { base.AttachBehaviors(region, regionTarget); } protected override void Adapt(IRegion region, RadPaneGroup regionTarget) { region.Views.CollectionChanged += (s, e) => { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems.OfType<RadPane>()) { regionTarget.Items.Add(item); } break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems.OfType<RadPane>()) { //regionTarget.Items.Remove(item); item.RemoveFromParent(); } break; case NotifyCollectionChangedAction.Replace: var oldItems = e.OldItems.OfType<RadPane>(); var newItems = e.NewItems.OfType<RadPane>(); var newItemsEnumerator = newItems.GetEnumerator(); foreach (var oldItem in oldItems) { var parent = oldItem.Parent as ItemsControl; if (parent != null && parent.Items.Contains(oldItem)) { parent.Items[parent.Items.IndexOf(oldItem)] = newItemsEnumerator.Current; if (!newItemsEnumerator.MoveNext()) { break; } } else { oldItem.RemoveFromParent(); regionTarget.Items.Add(newItemsEnumerator.Current); } } break; case NotifyCollectionChangedAction.Reset: regionTarget .EnumeratePanes() .ToList() .ForEach(p => p.RemoveFromParent()); foreach (var view in region.Views) { regionTarget.Items.Add(view); } break; default: break; } }; foreach (var view in region.Views.OfType<RadPane>()) { regionTarget.Items.Add(view); } } protected override IRegion CreateRegion() { return new AllActiveRegion(); } }
4. -- Docking Extension
public class DockingExtensions { public static bool GetRemovePanesWhenClosed(DependencyObject obj) { return (bool)obj.GetValue(RemovePanesWhenClosedProperty); } public static void SetRemovePanesWhenClosed(DependencyObject obj, bool value) { obj.SetValue(RemovePanesWhenClosedProperty, value); } public static readonly DependencyProperty RemovePanesWhenClosedProperty = DependencyProperty.RegisterAttached("RemovePanesWhenClosed", typeof(bool), typeof(DockingExtensions), new PropertyMetadata(false, OnRemovePanesWhenClosedPropertyChanged)); private static void OnRemovePanesWhenClosedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var newValue = (bool)e.NewValue; var dock = d as RadDocking; if (dock != null) { if (newValue) { dock.PreviewClose += dock_PreviewClose; } else { dock.PreviewClose -= dock_PreviewClose; } } } private static void dock_PreviewClose(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e) { foreach (var pane in e.Panes) { DependencyObject o = pane.Parent; pane.RemoveFromParent(); pane.Content = null; pane.Header = null; pane.DataContext = null; } e.Handled = true; } }