Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

New Post: How to set the title for LayoutAnchorable from MVVM binding?

$
0
0
Hi,

Unfortunately, the LayoutAnchorable is not part of the VisualTree, since a LayoutAnchorableControl will be created from it. But you can add a proxy which uses binding :
<StackPanel>
      <StackPanel.Resources>
            <FrameworkElement x:Key="ProxyElement"
                              DataContext="{Binding}" />
      </StackPanel.Resources>

      <ContentControl Visibility="Collapsed"
                      Content="{StaticResource ProxyElement}" />
      
      <xcad:DockingManager x:Name="DockingManager"
                           AllowMixedOrientation="True">
         <xcad:LayoutRoot x:Name="LayoutRoot">
            <xcad:LayoutPanel Orientation="Horizontal">
               <xcad:LayoutAnchorablePaneGroup DockWidth="3*"
                                               Orientation="Vertical">
                  <xcad:LayoutAnchorablePane DockHeight="*">
                     <xcad:LayoutAnchorable Title="{Binding DataContext.TitleToBeDisplayed, Source={StaticResource ProxyElement}}"
                                            AutoHideHeight="240"
                                            CanClose="False"
                                            CanHide="False">
                        <Button Content="TEST"/>
                     </xcad:LayoutAnchorable>
                  </xcad:LayoutAnchorablePane>
                  <xcad:LayoutAnchorablePane DockHeight="*">
                     <xcad:LayoutAnchorable Title="{Binding DataContext.TitleToBeDisplayed1, Source={StaticResource ProxyElement}}"
                                            AutoHideHeight="240"
                                            CanClose="False"
                                            CanHide="False">
                        <Button Content="TEST2" />
                     </xcad:LayoutAnchorable>
                  </xcad:LayoutAnchorablePane>
               </xcad:LayoutAnchorablePaneGroup>
            </xcad:LayoutPanel>
         </xcad:LayoutRoot>
      </xcad:DockingManager>
   </StackPanel>
And make sure to set the DataContext of the MainWindow to the control containing the the bounded properties :
this.DataContext = this;

Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>