dotnet / dotnet/wpf

Bad assert in VirtualizingStackPanel.EnsureScrollInfo

Open
#4,517 0 comments 0 reactions 0 assignees View on GitHub
.NET Framework Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: all
* Windows version: all
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? no

**Problem description:**
The following markup causes a Debug.Assert in `VirtualizingStackPanel.EnsureScrollInfo`

```





```

**Actual behavior:**
When using debug WPF bits, this asserts and either displays the assert dialog or simply crashes (depending on external factors). The assertion occurs when setting both Can*Scroll properties before the VSP is hooked up to a ScrollViewer.

**Expected behavior:**
No assert. The markup is legal.

**Minimal repro:**
[WpfApp5.zip](https://github.com/dotnet/wpf/files/6480889/WpfApp5.zip)

**Notes:**
The markup is actually useless. Instead, you should set the \*ScrollBarVisibility properties on the ScrollViewer. The ScrollViewer uses these properties to set the VSP's Can*Scroll properties, overriding the values from the ItemsPanelTemplate.

```

```

Nevertheless, the assertion should be removed. It's not valid, and it interferes with running an app that may have used the quoted markup. For example, Visual Studio 16.10.0 Preview 2.0.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.