Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Scroll Itemcontrol Content Fixed Header
    primarykey
    data
    text
    <p>Is it possible to do something like this with WPF's ItemsControl: <a href="http://jqueryfordesigners.com/demo/header-slide.html" rel="nofollow noreferrer">Demo</a></p> <p>I am trying to freeze the GroupedItems rather than the GridView Columns.</p> <p><img src="https://i.stack.imgur.com/nUp9h.png" alt="enter image description here"></p> <p>Resources:</p> <pre><code>&lt;Window.Resources&gt; &lt;CollectionViewSource x:Key="data" Source="{Binding}"&gt; &lt;CollectionViewSource.GroupDescriptions&gt; &lt;PropertyGroupDescription PropertyName="Date"/&gt; &lt;/CollectionViewSource.GroupDescriptions&gt; &lt;/CollectionViewSource&gt; &lt;/Window.Resources&gt; </code></pre> <p>ListView:</p> <pre><code>&lt;ListView Grid.Column="0" ItemsSource="{Binding Source={StaticResource data}}"&gt; &lt;ListView.View&gt; &lt;GridView&gt; &lt;GridView.Columns&gt; &lt;GridViewColumn Header="Col 1" DisplayMemberBinding="{Binding Col1}" Width="100"/&gt; &lt;GridViewColumn Header="Col 2" DisplayMemberBinding="{Binding Col2}" Width="100"/&gt; &lt;GridViewColumn Header="Col 3" DisplayMemberBinding="{Binding Col3}" Width="100"/&gt; &lt;/GridView.Columns&gt; &lt;/GridView&gt; &lt;/ListView.View&gt; &lt;ListView.GroupStyle&gt; &lt;GroupStyle&gt; &lt;GroupStyle.ContainerStyle&gt; &lt;Style TargetType="{x:Type GroupItem}"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type GroupItem}"&gt; &lt;Grid&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid Grid.Row="0"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="*"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;TextBlock Background="Beige" FontWeight="Bold" Text="{Binding Path=Name, StringFormat={}{0}}"/&gt; &lt;/Grid&gt; &lt;DockPanel Grid.Row="1"&gt; &lt;ItemsPresenter Grid.Row="2"&gt;&lt;/ItemsPresenter&gt; &lt;/DockPanel&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/GroupStyle.ContainerStyle&gt; &lt;/GroupStyle&gt; &lt;/ListView.GroupStyle&gt; &lt;/ListView&gt; </code></pre> <p>CODE BEHIND:</p> <pre><code>public MainWindow() { InitializeComponent(); List&lt;String&gt; colList1 = new List&lt;string&gt;(){"Item1", "Item2", "Item3", "Item4", "Item5", "Item6", "Item7"}; List&lt;String&gt; colList2 = new List&lt;string&gt;(){"1", "2", "3", "4", "5", "6"}; ObservableCollection&lt;Data&gt; dataCollection = new ObservableCollection&lt;Data&gt;(); for (var a = 0; a&lt;100; a++){ Random rnd = new Random(); int min = rnd.Next(5000); int rnd1 = rnd.Next(0, 6); int rnd2 = rnd.Next(0, 5); dataCollection .Add( new Data(){ Date = DateTime.Now.AddMinutes(min).ToString("hh:MM tt"), Col1= colList1[rnd2], Col2= String.Format("Col2: {0}", "X"), Col3= colList2[rnd2] } ); } this.DataContext = dataCollection; } public class Data { public string Date { get; set; } public string Col1{ get; set; } public string Col2{ get; set; } public string Col3{ get; set; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    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