I have a WPF window that contains three items controls, along with 3 buttons. Is there any way using PrintVisual() that I can print just two of the items controls, and no buttons?
My first thought was to dynamically create a StackPanel and add the controls that I wanted to print to it, but I can’t do that without detaching them first and it seems problematic.
I would like to use PrintVisual because it’s so simple. (Unfortunately I can’t spend too much time on this application).
***Please forgive the lack of source code supplied, but I’m relatively new to WPF and currently my form is grotesquely over-coded. I guess I’m just curious if there is a simple solution out there.
Thanks.
If your concern is only printing a part of the page. Place your two items controls that you want to print inside a Grid element. Give it a name
Then you can call PrintDialog.PrintVisual like
If you cannot manage to group only those controls into their own grid you could do it manually by creating a Container in code and adding your existing named itemsControls to them. Then you can PrintVisual the container.