DataGrid and ScrollBar styling WPF - c#

I'm creating DataGrid style in WPF. Now I have rounded corners in my DataGrid, but when appears ScrollBar, it looks not beautiful. DataGridHeader corner is still rounded, and I can see space between corners of ScrollBar button and DataGridHeader. Here is an image:
I need to show rounded corners only when DataGrid hasn't ScrollBar.In all other cases I need to show this:
So how to remove dynamicaly that space on the first image?

Style Scrollbar so that it overlaps the the grid by using negative left margin value

Related

Horizontal percentage stretching of children

What component in MAUI would I use to accomplish such a chart?
It should stretch to 100% width and the elements should have relative widths.
Is this possible with XAML only?
I thought about a grid with one row, but I can't iterate over the children.
Or a horizontal stackpanel, but it won't stretch.
Any idea?

Render an image and overlaid controls in exact pixels?

I have a background image that consists of an outline, with 10 rectangles placed specifically on the outline. I want to display that image on the screen, and overlay transparent buttons that match up to the rectangles on the image. When the button is pressed, the button's outline will turn to orange to indicate the rectangle has been selected.
I'm finding that simply setting the width and height of the buttons to match the pixel width and height of the rectangles in the image always renders a button much larger than the corresponding rectangle.
The image itself is 669 x 871px, and the rectangles are all 87 x 143px. Setting the Image's WidthRequest and HeightRequest in code or in XAML seems to render it at a different resolution than it actually is, thereby leading to the issue I described - if a button's size is set to 87 x 143 (again using HeightRequest and WidthRequest) it always renders larger than the rectangle.
Furthermore, if I contain the buttons in a StackLayout (as I often need to do) and specify a margin to push the layout downwards to align with the rectangles on the image, again the correct number of pixels never matches up with the distance the layout is moved.
I'm aware of how to overlay elements using a Grid with a single row and column and simply defining multiple layouts in the same space and triggering visibility in code. What I don't know how to do is display the elements in exactly the right pixel sizes that I need for the controls to always align with the image.
The diagram I'm working with:
Desired behaviour:
Actual behaviour:
I've worked out how to do this by using Grids within a Grid. By setting the Grid's row and column height and width to "*" (use all available space), defining a ContentView containing the diagram, then several smaller grids to lay over the top with their row height and column width matching the dimensions of the diagram image (i.e. if the image is 600 pixels wide, the nested Grid's ColumnDefinition's Width="600"),
I was then able to define the buttons inside a StackLayout, inside the nested Grids. I've tried this out across a few different resolutions and it seems to work just fine for my purposes.
I had to set Padding to 0, and used the Margin to vertically align the StackLayout as needed (i.e. for the first row of buttons at the top of the diagram, their StackLayout's Margin was "19,89,19,0" - 19 pixels from either side, 89 pixels from the top).

Hide/Show Richtextbox Bottom Border in WPF?

i want to hide/show bottom border of richtextbox in WPF.I already use 10,10,10,-10 for hiding bottom border.it works.but my text content are partially shown for using this method and i cant get the proper panning.So how to hide/show bottom border without extent the value in negative.
Regards
Arjun
Set the bottom border thickness to 0.
BorderThickness="10,10,10,0"

Aligning vertical or horizontal grids with percentage in WinForms

I'm working on a winforms User Control . There are several grids on it. Some of them are horizontally aligned and some of them are vertically aligned.
I'm embedding the User Control in a Form and i'm setting
this.Dock = DockStyle.Fill;
On the run, i want the grids to be scaled horizontally or vertically when fulscreen or minimized screen but i see the absolute heights and widths of grids. For example in minimized screen only the grid on the left is visible and when I make fulscreen I see the right grid.(the same for above and below grids)
How can I make them to be scaled relatively whatever the ecreen size is?
You could separate the grids with SplitContainers(Just nest as much of them as you need). Set FixedPanel to None so that the panels in the splitcontainer are sized relatively to each other. Set IsSplitterFixed to true to prohibit manual resizing. When you anchor your grids to all sides or set DockStyle to Fill you should get what you want.

Scrollbar Style

How can I remove the small rectangle that appears when a horizontal and vertical scrollbar appear?
I assume you are using a ScrollViewer. The default template of a ScrollViewer is a Grid containing two rows and two columns. The upper left cell contains the ScrollViewer content, upper right the vertical ScrollBar, lower left the horizontal ScrollBar, and a Rectangle on the lower right cell. Please check this article: http://www.eggheadcafe.com/tutorials/aspnet/f51ddf8c-5227-4f1b-a5df-ec3d1b3439ca/styling-the-wpf-scrollviewer.aspx. You can see the default template there. You could remove the rectangle and then set either the ColumnSpan of the horizontal ScrollBar or RowSpan of the vertical ScrollBar to cover the lower right cell. Hope this helps.

Categories