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

WardH 61 Reputation points
2020-05-09T08:22:09.297+00:00

Hi,

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.

Thanks,

Ward.

Current XAML Code:

8063-xaml.txt

How it looks now:

8071-inkedcurrent-window-li.jpg

Idea on how to look mockup:

7937-grid-idea.png

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,706 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaodi Yan 876 Reputation points MVP
    2020-05-10T07:41:38.217+00:00

    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.

    FYI:
    https://stackoverflow.com/questions/83319/wpf-3-5-webbrowser-control-and-zindex

    https://stackoverflow.com/questions/980334/wpf-webbrowser-3-5-sp1-always-on-top-other-suggestion-to-display-html-in-wpf

    https://stackoverflow.com/questions/20972231/wpf-webbrowser-floating-on-all-controls-outside-grid

    https://stackoverflow.com/questions/9994933/wpf-c-sharp-webbrowser-scrolls-over-top-menu

    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://video2.skills-academy.com/en-us/dotnet/framework/wpf/advanced/flow-document-overview

    0 comments No comments

0 additional answers

Sort by: Most helpful