Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks Jefim and Rachel for pushing me into the right direction. For me the missing link was actually the MaxHeight on the CheckGroup DataTemplate as Jefim pointed out. </p> <p>I now set MaxHeight to the axtual height of the window minus some height to make sure the other groups stay visible. </p> <p>I know this might look like a dirty solution, but with some nifty wpf brushes it will look sweet and the behavior is very close to my expectations!</p> <p>Changes to the code to become the behavior I wanted:</p> <p>MainWindow.xaml</p> <pre><code>&lt;Window x:Class="VerticalWrapPanel.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:VerticalWrapPanel" xmlns:converters="clr-namespace:VerticalWrapPanel" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded" x:Name="MyWindow"&gt; &lt;Window.Resources&gt; &lt;converters:ActualHeightReduce x:Key="ActualHeightReduce" /&gt; &lt;DataTemplate x:Key="CheckGroupsTemplate"&gt; &lt;controls:CheckGroupControl MaxHeight="{Binding ElementName=MyWindow, Path=ActualHeight, Converter={StaticResource ActualHeightReduce}}" /&gt; &lt;/DataTemplate&gt; &lt;/Window.Resources&gt; &lt;ScrollViewer CanContentScroll="False"&gt; &lt;ItemsControl ItemsSource="{Binding CheckGroups}" ItemTemplate="{StaticResource CheckGroupsTemplate}" /&gt; &lt;/ScrollViewer&gt; &lt;/Window&gt; </code></pre> <p>Addition to MainWindow.xaml.cs (inside the namespace VerticalWrapPanel)</p> <pre><code>public class ActualHeightReduce : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if (value == null || string.IsNullOrEmpty(value.ToString())) return value; double vValue; if (Double.TryParse(value.ToString(), out vValue)) { return vValue - 75; } return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return Binding.DoNothing; } } </code></pre> <p>And the CheckGroupControl.xaml now has a nice horizontal scroll:</p> <pre><code>&lt;UserControl x:Class="VerticalWrapPanel.CheckGroupControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:VerticalWrapPanel" x:Name="GroupControl"&gt; &lt;UserControl.Resources&gt; &lt;DataTemplate x:Key="CheckTemplate"&gt; &lt;controls:CheckControl /&gt; &lt;/DataTemplate&gt; &lt;/UserControl.Resources&gt; &lt;Expander BorderBrush="Black" Header="TEST" IsExpanded="{Binding ElementName=GroupControl, Path=IsExpanded}"&gt; &lt;ItemsControl ScrollViewer.VerticalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Auto" ItemsSource="{Binding Checks}" ItemTemplate="{StaticResource CheckTemplate}"&gt; &lt;ItemsControl.Template&gt; &lt;ControlTemplate&gt; &lt;ScrollViewer x:Name="ScrollViewer" Padding="{TemplateBinding Padding}"&gt; &lt;ItemsPresenter /&gt; &lt;/ScrollViewer&gt; &lt;/ControlTemplate&gt; &lt;/ItemsControl.Template&gt; &lt;ItemsControl.ItemsPanel&gt; &lt;ItemsPanelTemplate&gt; &lt;WrapPanel Orientation="Vertical" IsItemsHost="True" /&gt; &lt;/ItemsPanelTemplate&gt; &lt;/ItemsControl.ItemsPanel&gt; &lt;/ItemsControl&gt; &lt;/Expander&gt; &lt;/UserControl&gt; </code></pre> <p>And of course the Orientation of the wrappanel in the CheckControl still has to be set to Vertical ;)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload