PRISM Scrolling in region

I use regions with Prism. In the main window I have defined regions and in the region LeftNavigationRegion I inject a module which consist of basically a treeview. When the main region resizes I want a scrollbar from the treeview, but I instead get the scrollbar from the content control. This means that the header control in the treeview disappears. Does anyone know how to show the scrollbar of the treeview

XAML in main window...

<ContentControl  x:Name="ActionContent"
                 cal:RegionManager.RegionName="{x:Static inf:RegionNames.LeftNavigationRegion}"
                 VerticalAlignment="Stretch">
    <ContentControl.Template>
        <ControlTemplate TargetType="ContentControl">
            <ContentPresenter  Content="{TemplateBinding Content}" />
            <ControlTemplate.Triggers>
                <Trigger Property="HasContent" Value="false">
                    <Setter Property="Visibility" Value="Collapsed" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </ContentControl.Template>
</ContentControl>

Answers


You need to limit the size of the TreeView in some way. By default, it is probably being allowed to stretch to whatever size it needs, so the TreeView doesn't think it ever needs to scroll so don't show it's ScrollBars

You can do this by binding the Height/Width of the TreeView to your ContentControl's Height/Width. (If your outer ScrollViewer is inside the ContentControl, then bind to the it's Height/Width instead)

<TreeView Height="{Binding ElementName=ActionContent, Path=ActualHeight}"
          Width="{Binding ElementName=ActionContent, Path=ActualWidth}">

Think i solved it, the problem was related to how i renderede the treeview columns, i was using a static Grid inside the style template of the treeview. When i realized that if i changed my custom treeview to a standard listview the scrolling worked. So i extracted the styles for the standard listview and made some changes to the treeview style and it worked, now the header for the treeview stays on top and the scrollbar for the treeview is shown instead of the scrollbar for the content control

In

<Style TargetType="{x:Type TreeView}".....

is added

                <Border BorderThickness="{TemplateBinding Border.BorderThickness}" BorderBrush="{TemplateBinding Border.BorderBrush}" Name="Bd" SnapsToDevicePixels="True">

                    <ScrollViewer Style="{DynamicResource
                {x:Static GridView.GridViewScrollViewerStyleKey}}">
                        <ItemsPresenter />
                    </ScrollViewer>

                </Border>

for the control template. And in

<Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="ScrollViewer">

I added

  <ScrollViewer DockPanel.Dock="Top"
                          HorizontalScrollBarVisibility="Hidden"
                          VerticalScrollBarVisibility="Hidden"
                          Focusable="false">
                                    <GridViewHeaderRowPresenter Name="hrp" Columns="{StaticResource gvcc}"  
                                ColumnHeaderContainerStyle=
                                 "{StaticResource MyHeaderStyle}" />
                                </ScrollViewer>

So i can define my columns outside from style as treeview does not have .view property

Hope this helps someone and thanks Rachel for your efforts


Need Your Help

After successful open(), program is stalling on read()

c io low-level-io

I've been banging my head against my desk for a few hours now, trying to figure out why the following code is stalling at while(chars = read(fd, buff, BUFF_SZ)) &gt; 0). The printf on the line dire...

Can I add HTML button triggers to update panel

c# javascript gridview webforms updatepanel

Is it possible to add HTML input buttons to asp.net triggers, as I have a message box it works perfectly for a gridview which is in update panel,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.