0

I am currently developing a control that has a DataGrid as the main parent and one of the columns is a listview which has another listview inside.

I am trying to re-evaluate the scroll content when I modify dynamically the node size from the listview.

 <DataGrid  ItemsSource="{Binding ItemsCollection}" AutoGenerateColumns="False" FrozenColumnCount="2" ColumnHeaderHeight="30"
                 SelectionMode="Single"
                 SelectionUnit="Cell"
                 ScrollViewer.CanContentScroll="True"
                 PreviewMouseWheel="DataGridControl_OnPreviewMouseWheel"
                 CanUserResizeColumns="False"
                 GridLinesVisibility="Vertical"
                 CanUserDeleteRows="False">
 <DataGrid.Columns>
      <DataGridTextColumn/> <!-- Some simple binding here -->
      <DataGridTextColumn/> <!-- Some simple binding here -->
      <DataGridTemplateColumn Header="Sequence">
          <DataGridTemplateColumn.CellTemplate>
             <DataTemplate>
                 <ListView ItemsSource="{Binding Path=Items}">
                      <ListView.Template>
                           <ControlTemplate TargetType="ItemsControl">
                              <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" Name="ItemsScroll">
                                 <ItemsPresenter />
                              </ScrollViewer>
                           </ControlTemplate>
                        </ListView.Template>
                        <ListView.ItemsPanel>
                           <ItemsPanelTemplate>
                              <WrapPanel/>
                           </ItemsPanelTemplate>
                        </ListView.ItemsPanel>
                        <ListView.ItemTemplate>
                           <DataTemplate>
                              <Grid Margin="2" Name="BorderText">
                                  <ListView ItemsSource="{Binding OPs, UpdateSourceTrigger=PropertyChanged}" 
                                       <ListView.ItemTemplate>
                                          <DataTemplate>
                                             <Border BorderBrush="Green" BorderThickness="2" Margin="4" Height="40">
                                                <Border.Width>
                                                   <MultiBinding Converter="{StaticResource SizeConverter}">
                                                      <Binding Path="DataContext.NodeSize" RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type Window}}" />
                                                      <Binding Path="Seconds" UpdateSourceTrigger="PropertyChanged" />
                                                   </MultiBinding>
                                                </Border.Width>

                                                <Grid>
                                                   <Grid.RowDefinitions>
                                                      <RowDefinition/>
                                                      <RowDefinition/>
                                                   </Grid.RowDefinitions>
                                                   <TextBlock Text="{Binding Name}" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="0"/>

                                                   <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Row="1" >
                                                      <Run Text="{Binding Seconds}"/>
                                                      <Run Text=" sec"/>
                                                   </TextBlock>
                                                </Grid>
                                             </Border>
                                          </DataTemplate>
                                       </ListView.ItemTemplate>
                                       <ListView.ItemsPanel>
                                          <ItemsPanelTemplate>
                                             <WrapPanel/>
                                          </ItemsPanelTemplate>
                                       </ListView.ItemsPanel>
                                    </ListView>
                                 </Border>
                              </Grid>
                           </DataTemplate>
                        </ListView.ItemTemplate>
                     </ListView>
                  </DataTemplate>
          </DataGridTemplateColumn.CellTemplate>
      </DataGridTemplateColumn>
 </DataGrid.Columns>
</DataGrid>

On PreviewMouseWheel I am resizing the node size of the second listview. This DataGrid has two fixed columns and after that a column that its nodes can be resized on width.

If I "zoom out" then the DataGrid scrollviewer resizes properly. When I try to "zoom in" the scrollviewer keeps the max size of the content and I need the scrollviewer to resize based on the current visibile size.

When opening the application:

enter image description here

When zoom out: enter image description here

After that when I zoom in the size of the scrollviewer remains the same enter image description here

Any idea how to solve this issue?

2
  • Try this on ListView ScrollViewer.CanContentScroll="False" Commented Jun 10, 2024 at 16:44
  • @MustafaMutasim Sadly, it's still the same effect. No resize of the content area Commented Jun 11, 2024 at 5:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.