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:
After that when I zoom in the size of the scrollviewer remains the same

Any idea how to solve this issue?

ScrollViewer.CanContentScroll="False"