question

WardH-0381 avatar image
0 Votes"
WardH-0381 asked ·

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

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-wpf
grid-idea.png (40.5 KiB)
xaml.txt (2.1 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

yanxiaodi avatar image
0 Votes"
yanxiaodi answered ·

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

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.