C# .NET Core WPF Listbox items outside grid cell.

WardH 61 Reputation points


I want to have a listbox which contains two items a Checkbox and a WebBrowser control.

I have the listbox appearing in the center cell on my WPF Window. However if there are more then one item then it exceeds the cell and drops to the cell below.

What I for the whole listbox not to exceed its middle cell. However the visual to stretch horizontally. Any additional content would then have a horizontal scroll bar.

Vertically however for the web control it would grow vertically to take as much space as needed but not exceed the bounds of the cell.

I have posted the XAML I have plus what the output looks like now. and an image to try to show what I am after. You can see from the image how the second item exceeds it bounds.



Current XAML Code:


How it looks now:


Idea on how to look mockup:


Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,709 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaodi Yan 876 Reputation points MVP

    I'm not sure if the web browser control has been improved in .net core 3.1 but in the old .net framework, the web browser is not a common WPF control. You cannot set its Z-Index, which means it always shows on the top of the whole window. I guess it has the same behavior in .net core 3.1.





    Also, it looks a little bit weird to put the web browsers in the list box because both have scroll bars. One way is to convert the HTML content to Flow Document. FYI: https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/flow-document-overview

    0 comments No comments

0 additional answers

Sort by: Most helpful