RichEditBox - "Delayed" window resizing behavior when resizing a window - does not "attach" to the top or bottom of the grid cell

I searched around the world for the answer to this question and came to my senses. I use universal Windows 10 (UWP) and C # in Visual Studio 2015 to create a basic text editor to reflect Notepad.exe functionality as a practice, and I came across an annoying / quirk display problem.

I have a grid with two rows. The top row is a horizontal StackPanel with buttons, and the bottom row is a RichEditBox . Everything is displayed normally. RichEditBox has keyboard focus (which I pretty much believe is always the case), and I resize the window vertically, the RichEditBox (and its green border) resize other than the Grid container. When I drag the window down to resize, the RichEditBox border β€œseparates” from the top and bottom and quickly moves up (and down) to fill the grid. However, the text trembles during this animation. Note: this does NOT happen when I resize horizontally. (the image link below this will not let me embed the pic.)

Unwanted resizing

This is not the end of the world, but it looks unprofessional, and there should be a way to snap the RichEditBox vertically so that it always completely fills the series of grids and does not move apart from its container when resizing. I tried all the properties on Grid.Row , RichEditBox and its built-in ScrollViewer , which, as I thought, might have something to do with this and no luck. Using VerticalAlignment = Top causes the RichEditBox no longer fill the grid line vertically (unless I fill it with text, of course). I also put a RichEditBox inside a ScrollViewer instead of using its built-in ScrollViewer , and it did the same behavior.

Here is my XAML:

  <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*" /> </Grid.RowDefinitions> <StackPanel Orientation="Horizontal" Height="Auto" Grid.Row="0" Background="Azure" AllowFocusOnInteraction="False"> <Button x:Name="FileButton" Content="File" Click="MenuButtonClicked" Padding="3,1" Background="Azure"> <Button.Flyout> <MenuFlyout Placement="Bottom"> <MenuFlyoutItem Text="New" Click="NewClicked" /> <MenuFlyoutItem Text="Open..." Click="OpenClicked" /> <MenuFlyoutItem Text="Save" Click="SaveClicked" /> <MenuFlyoutItem Text="Save As..." Click="SaveAsClicked" /> <MenuFlyoutItem Text="Close" Click="CloseClicked" /> <MenuFlyoutSeparator/> <MenuFlyoutItem Text="Exit" Click="ExitClicked" /> </MenuFlyout> </Button.Flyout> </Button> <Button x:Name="EditButton" Content="Edit" Click="MenuButtonClicked" Padding="3,1" Background="Azure"> <Button.Flyout> <MenuFlyout Placement="Bottom"> <MenuFlyoutItem Text="Undo" Click="UndoClicked" /> <MenuFlyoutSeparator/> <MenuFlyoutItem Text="Cut" Click="CutClicked" /> <MenuFlyoutItem Text="Copy" Click="CopyClicked" /> <MenuFlyoutItem Text="Paste" Click="PasteClicked" /> <MenuFlyoutItem Text="Clear" Click="ClearClicked" /> <MenuFlyoutSeparator/> <MenuFlyoutItem Text="Date/Time" Click="DateTimeClicked" /> <MenuFlyoutItem Text="Select All" Click="SelectAllClicked" /> </MenuFlyout> </Button.Flyout> </Button> <Button x:Name="FormatButton" Content="Format" Click="MenuButtonClicked" Padding="3,1" Background="Azure"> <Button.Flyout> <MenuFlyout Placement="Bottom"> <ToggleMenuFlyoutItem Text="Word Warp" Click="WordWrapToggled" IsChecked="True"/> </MenuFlyout> </Button.Flyout> </Button> <Button x:Name="HelpButton" Content="Help" Click="MenuButtonClicked" Padding="3,1" Background="Azure"> <Button.Flyout> <MenuFlyout Placement="Bottom"> <MenuFlyoutItem Text="About" Click="AboutClicked" /> </MenuFlyout> </Button.Flyout> </Button> </StackPanel> <RichEditBox x:Name="MainTextBox" FontFamily="Consolas" FontSize="14" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" IsSpellCheckEnabled="False" BorderThickness="1" TabIndex="0" ScrollViewer.IsVerticalRailEnabled="True" ScrollViewer.VerticalScrollMode="Auto" ScrollViewer.IsHorizontalRailEnabled="True" ScrollViewer.HorizontalScrollMode="Auto" KeyDown="TabKeyDown" Paste="ContentPasted" /> </Grid> 

Does anyone know how to make this behave the way I want?

I am grateful for any help that anyone can give.

+5
source share

Source: https://habr.com/ru/post/1265469/


All Articles