Home Forums WPF controls Xceed Toolkit Plus for WPF What activates the LayoutUpdateStrategy?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • Nasheayah
    Participant
    Post count: 4
    #48222 |

    Looking over the Edi and AvalonDock.MVVMTestApp examples I’m not using the LayoutItemTemplateSelector and LayoutItemContainerStyleSelector. Are these needed to activate the LayoutUpdateStrategy event?

    I’m programmatically adding LayoutAnchorable’s to the AnchorablesSource=”{Binding Tools}” using Prism to Initialize the View:

    SqlCeOptionsView doc = ServiceLocator.Current.GetInstance<ISqlCeOptionsView>(layoutType.Item1) as SqlCeOptionsView;
    LayoutAnchorable layoutAnchorable = new LayoutAnchorable
    {
    Content = doc,
    Title = layoutProperties.Title,
    IconSource = new BitmapImage(new Uri(@layoutProperties.IconSource)),
    CanClose = layoutProperties.CanClose
    };

    _tools.Add(layoutAnchorable);

    But the BeforeInsertAnchorable event is not kicking.

    Diane [Xceed]
    Moderator
    Post count: 1353

    Hi Nasheayah,

    Are you referring to AvalonDock.MVVMTestApp that can be found here:
    https://github.com/chandramouleswaran/AvalonDock

    If yes, I downloaded an ran that sample (making sure to reference the latest AvalonDock dll).

    No, using LayoutItemTemplateSelector or LayoutItemContainerStyleSelector are not needed to activate the LayoutUpdateStrategy event. Just make sure, like in the sample, that an avalonDock:DockingManager.LayoutUpdateStrategy is set.

    To test this sample:
    1) I put a breakpoint in LayoutInitializer.BeforeInsertAnchorable().
    2) I modified the Tools in Workspace to be an ObservableCollection<ToolViewModel> instead of a ToolViewModel[].
    3) I added a button in MainWindow.xaml where in its Button_click event, I did:

       var workspace = this.DataContext as Workspace;
       if( workspace != null )
       {
          ToolViewModel t = new ToolViewModel( "ABC" );
          workspace.Tools.Add( t );
       }

    Result: The breakpoint is hit when the button is clicked (when adding an item in Tools).

    Nasheayah
    Participant
    Post count: 4

    Hi Diane,

    Thanks for the reply, I think I may have found the problem, but you can tell me if I’m correct or not. After looking over my XAML,

    <Metro:HamburgerMenu x:Name="ShellHamburgerMenu" Grid.Row="2"
    					...
    					..
    					.
    					 ContentTemplate="{StaticResource HamburgerContentTemplate}"
    					 ...
    					 ..
    					 .
    					 prism:RegionManager.RegionName="{x:Static uiCommon:RegionNames.LayoutMainViewRegion}">
    </Metro:HamburgerMenu>

    The Template:

    <DataTemplate x:Key="HamburgerContentTemplate" DataType="{x:Type ModelType:HambgrMenuItemTS}">
    	<Grid>
    		<Metro:SplitView x:Name="OptionSplitview"
    					Margin="0"
    					DisplayMode="Inline"
    					IsPaneOpen="{Binding Path=SelectedItem.IsPaneOpen, RelativeSource={RelativeSource AncestorType={x:Type Metro:HamburgerMenu}}}"
    					OpenPaneLength="250"
    					>
    			<Metro:SplitView.Pane>
    				<StackPanel>
    
    				</StackPanel>
    			</Metro:SplitView.Pane>
    			<xcad:DockingManager Grid.Row="2" x:Name="DockingManager" AllowMixedOrientation="True"
    								AnchorablesSource="{Binding Tools}" 
    								DocumentsSource="{Binding Files}"
    				 TextBlock.Foreground="{DynamicResource MaterialDesignBody}" Background="{DynamicResource MaterialDesignBackground}" Margin="5">
    				 ...
    				 ..
    				 .
    				<xcad:DockingManager.LayoutUpdateStrategy>
    					<behavior:LayoutInitializer/>
    				</xcad:DockingManager.LayoutUpdateStrategy>
    				<xcad:LayoutRoot x:Name="_LayoutRoot">
    					<xcad:LayoutPanel x:Name="_RootPanel" Orientation="Horizontal">
    						<xcad:LayoutAnchorablePane x:Name="_LayoutAnchorablePane"/>
    						<xcad:LayoutDocumentPaneGroup >
    							<xcad:LayoutDocumentPane x:Name="_LayoutDocumentGroupPane"/>
    
    						</xcad:LayoutDocumentPaneGroup>
    						<xcad:LayoutAnchorablePaneGroup DockWidth="125">
    							<xcad:LayoutAnchorablePane/>
    						</xcad:LayoutAnchorablePaneGroup>
    					</xcad:LayoutPanel>
    
    					<xcad:LayoutRoot.LeftSide>
    						<xcad:LayoutAnchorSide x:Name="_LayoutAnchorableSideLeft">
    							<xcad:LayoutAnchorGroup x:Name="_LayoutAnchorableGroupLeft"/>
    						</xcad:LayoutAnchorSide>
    					</xcad:LayoutRoot.LeftSide>
    					<xcad:LayoutRoot.RightSide>
    						<xcad:LayoutAnchorSide x:Name="_LayoutAnchorableSideRight" >
    							<xcad:LayoutAnchorGroup  x:Name="_LayoutAnchorableGroupRight"/>
    						</xcad:LayoutAnchorSide>
    					</xcad:LayoutRoot.RightSide>
    					<xcad:LayoutRoot.BottomSide>
    						<xcad:LayoutAnchorSide x:Name="_LayoutAnchorableSideBottom">
    							<xcad:LayoutAnchorGroup  x:Name="_LayoutAnchorableGroupBottom"/>
    						</xcad:LayoutAnchorSide>
    					</xcad:LayoutRoot.BottomSide>
    				</xcad:LayoutRoot>
    
    			</xcad:DockingManager>
    
    		</Metro:SplitView>
    
    	</Grid>
    </DataTemplate>

    I decided to take the DockingManager out of the ContentTemplate | DataTemplate, created another View, put it into a Metro:SplitView without a Template just to see what happens and it worked. So, I’m assuming the DataTemplate had some effect, because when I Step Debugged, I found my defined LayoutRoot Children where missing.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.