Skip to content

Commit df60c1b

Browse files
authored
[DevExpress] Fix ScrollView for multiline TextBox (#136)
1 parent ef96414 commit df60c1b

File tree

8 files changed

+198
-116
lines changed

8 files changed

+198
-116
lines changed

samples/SampleApp/DemoPages/ScrollViewerDemo.axaml

+15-12
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
5+
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="700"
66
x:Class="SampleApp.DemoPages.ScrollViewerDemo">
77
<Border Padding="10">
88
<StackPanel>
9-
<Grid ColumnDefinitions="Auto, 420, 420" RowDefinitions="Auto, 320, 320">
9+
<Grid ColumnDefinitions="Auto, 400, 400" RowDefinitions="Auto, 320, 320">
1010
<TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center">Default</TextBlock>
1111
<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" Classes="code">Classes="MacOS_TransparentTrack"</TextBlock>
1212
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center">Default</TextBlock>
1313
<Border Grid.Row="1" Grid.Column="1" Background="{DynamicResource BackgroundBrush}"
14-
BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1" Width="400"
14+
BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1" Width="380"
1515
Height="300">
16-
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5 ">
17-
<StackPanel Background="{DynamicResource BackgroundBrush}">
16+
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5">
17+
<StackPanel Background="{DynamicResource BackgroundBrush}" Width="400">
1818
<TextBlock>drwxr-xr-x 26 jdoe staff 832 28 Jan 14:27 .</TextBlock>
1919
<TextBlock>drwxr-xr-x@ 17 jdoe staff 544 29 Jan 11:59 ..</TextBlock>
2020
<TextBlock>-rw-r--r--@ 1 jdoe staff 6148 28 Jan 14:27 .DS_Store</TextBlock>
@@ -46,18 +46,19 @@
4646
</Border>
4747

4848
<Border Grid.Row="1" Grid.Column="2" BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1"
49-
Width="400" Height="300">
49+
Width="380" Height="300">
5050
<ScrollViewer HorizontalScrollBarVisibility="Auto" Classes="MacOS_TransparentTrack">
5151
<Image Width="800" Height="600"
5252
Source="avares://SampleApp/Assets/SampleImage.jpg" />
5353
</ScrollViewer>
5454
</Border>
5555

5656
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Classes="code" VerticalAlignment="Center">AllowAutoHide="False"</TextBlock>
57-
<Border Grid.Row="2" Grid.Column="1" BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1"
58-
Width="400" Height="300">
59-
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5 " AllowAutoHide="False">
60-
<StackPanel Background="{DynamicResource BackgroundBrush}">
57+
<Border Grid.Row="2" Grid.Column="1" Background="{DynamicResource BackgroundBrush}"
58+
BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1" Width="380"
59+
Height="300">
60+
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5" AllowAutoHide="False">
61+
<StackPanel Background="{DynamicResource BackgroundBrush}" Width="400">
6162
<TextBlock>drwxr-xr-x 26 jdoe staff 832 28 Jan 14:27 .</TextBlock>
6263
<TextBlock>drwxr-xr-x@ 17 jdoe staff 544 29 Jan 11:59 ..</TextBlock>
6364
<TextBlock>-rw-r--r--@ 1 jdoe staff 6148 28 Jan 14:27 .DS_Store</TextBlock>
@@ -87,9 +88,8 @@
8788
</StackPanel>
8889
</ScrollViewer>
8990
</Border>
90-
9191
<Border Grid.Row="2" Grid.Column="2" BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1"
92-
Width="400" Height="300">
92+
Width="380" Height="300">
9393
<ScrollViewer HorizontalScrollBarVisibility="Auto" Classes="MacOS_TransparentTrack" AllowAutoHide="False">
9494
<Image Width="800" Height="600"
9595
Source="avares://SampleApp/Assets/SampleImage.jpg" />
@@ -101,6 +101,9 @@
101101
Since Avalonia ScrollBars only expand on pointerOver hiding them completely would be a bit confusing, so the Thumb sliders
102102
remain visible even when <TextBlock Classes="code" Text="AllowAutoHide=&quot;True&quot;" />.
103103
</TextBlock>
104+
<TextBlock TextWrapping="Wrap">
105+
<Bold>Note:</Bold> ScrollViewer content needs explicit width to avoid cutting off the right edge.
106+
</TextBlock>
104107
</StackPanel>
105108
</Border>
106109
</UserControl>

samples/SampleApp/MainWindow.axaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
xmlns:experiments="clr-namespace:SampleApp.Experiments"
77
xmlns:vm="clr-namespace:SampleApp.ViewModels"
88
xmlns:sampleApp="clr-namespace:SampleApp"
9-
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
9+
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="450"
10+
Width="1250"
11+
Height="800"
1012
x:Class="SampleApp.MainWindow"
1113
x:DataType="vm:MainWindowViewModel"
12-
Title="Devolutions MacOS Theme Sampler">
14+
Title="Devolutions Theme Sampler">
1315

1416
<!-- TODO: move the margins into the theme ?? -->
1517
<Panel Classes="mainControl">

src/Devolutions.AvaloniaTheme.DevExpress/Accents/ThemeResources.axaml

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
<SolidColorBrush x:Key="TextBoxBorderBrush" Color="{DynamicResource ControlBorderLowColorSolid}" />
100100
<SolidColorBrush x:Key="TextBoxBottomBorderBrush" Color="{DynamicResource TextBoxBorderBottomColor}" />
101101
<SolidColorBrush x:Key="TextBoxDisabledBorderSelectedBrush" Color="{DynamicResource ForegroundColor}" Opacity="0.1" />
102+
<Thickness x:Key="TextBoxPrefixPaddingFactors">1 1 0 1</Thickness>
103+
<Thickness x:Key="TextBoxSufixPaddingFactors">0 1 1 1</Thickness>
102104

103105
<SolidColorBrush x:Key="ComboBoxItemBackgroundBrush" Color="{DynamicResource BackgroundColor}" />
104106
<SolidColorBrush x:Key="ComboBoxDropDownBorderBrushTransparent" Color="{DynamicResource ForegroundColor}"

src/Devolutions.AvaloniaTheme.DevExpress/Controls/ScrollViewer.axaml

+70-18
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,76 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
33

44
<Design.PreviewWith>
5-
<ScrollViewer Width="200" Height="400"
6-
HorizontalScrollBarVisibility="Auto">
7-
<StackPanel Spacing="20" Width="210">
8-
<TextBlock>Item 1</TextBlock>
9-
<TextBlock>Item 2</TextBlock>
10-
<TextBlock>Item 3</TextBlock>
11-
<TextBlock>Item 4</TextBlock>
12-
<TextBlock>Item 5</TextBlock>
13-
<TextBlock>Item 6</TextBlock>
14-
<TextBlock>Item 7</TextBlock>
15-
<TextBlock>Item 8</TextBlock>
16-
<TextBlock>Item 9</TextBlock>
17-
</StackPanel>
18-
</ScrollViewer>
5+
<StackPanel Spacing="20" Margin="10">
6+
<Border Background="{DynamicResource BackgroundBrush}"
7+
BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1" Width="330"
8+
Height="300">
9+
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5">
10+
<StackPanel Background="{DynamicResource BackgroundBrush}">
11+
<TextBlock>drwxr-xr-x 26 jdoe staff 832 28 Jan 14:27 .</TextBlock>
12+
<TextBlock>drwxr-xr-x@ 17 jdoe staff 544 29 Jan 11:59 ..</TextBlock>
13+
<TextBlock>-rw-r--r--@ 1 jdoe staff 6148 28 Jan 14:27 .DS_Store</TextBlock>
14+
<TextBlock>-rw-r--r-- 1 jdoe staff 534 27 Jan 15:29 Add.svg</TextBlock>
15+
<TextBlock>-rw-r--r-- 1 jdoe staff 506 27 Jan 15:29 AddThin.svg</TextBlock>
16+
<TextBlock>-rw-r--r-- 1 jdoe staff 536 27 Jan 15:29 Computer.svg</TextBlock>
17+
<TextBlock>-rw-r--r-- 1 jdoe staff 909 27 Jan 15:29 CopyHost.svg</TextBlock>
18+
<TextBlock>-rw-r--r-- 1 jdoe staff 795 27 Jan 15:29 CopyName.svg</TextBlock>
19+
<TextBlock>-rw-r--r-- 1 jdoe staff 986 27 Jan 15:29 CopyPassword.svg</TextBlock>
20+
<TextBlock>-rw-r--r-- 1 jdoe staff 1169 27 Jan 15:29 CopyUserName.svg</TextBlock>
21+
<TextBlock>-rw-r--r-- 1 jdoe staff 1189 27 Jan 15:29 CopyUserNamePassword.svg</TextBlock>
22+
<TextBlock>-rw-r--r-- 1 jdoe staff 749 27 Jan 15:29 Details.svg</TextBlock>
23+
<TextBlock>-rw-r--r-- 1 jdoe staff 888 27 Jan 15:29 DisableUser.svg</TextBlock>
24+
<TextBlock>-rw-r--r-- 1 jdoe staff 777 27 Jan 15:29 EnableUser.svg</TextBlock>
25+
<TextBlock>-rw-r--r-- 1 jdoe staff 368 27 Jan 15:29 Folder.svg</TextBlock>
26+
<TextBlock>-rw-r--r-- 1 jdoe staff 880 27 Jan 15:29 Help.svg</TextBlock>
27+
<TextBlock>-rw-r--r-- 1 jdoe staff 488 27 Jan 15:29 HorizontalLine.svg</TextBlock>
28+
<TextBlock>-rw-r--r-- 1 jdoe staff 564 27 Jan 15:29 More.svg</TextBlock>
29+
<TextBlock>-rw-r--r-- 1 jdoe staff 579 27 Jan 15:29 Padlock.svg</TextBlock>
30+
<TextBlock>-rw-r--r-- 1 jdoe staff 715 27 Jan 15:29 PasswordAnalyser.svg</TextBlock>
31+
<TextBlock>-rw-r--r-- 1 jdoe staff 1013 27 Jan 15:29 PrivateKey.svg</TextBlock>
32+
<TextBlock>-rw-r--r-- 1 jdoe staff 1275 27 Jan 15:29 Properties.svg</TextBlock>
33+
<TextBlock>-rw-r--r-- 1 jdoe staff 820 27 Jan 15:29 ResetPassword.svg</TextBlock>
34+
<TextBlock>-rw-r--r--@ 1 jdoe staff 147049 28 Jan 14:27 SampleImage.jpg</TextBlock>
35+
<TextBlock>-rw-r--r-- 1 jdoe staff 729 27 Jan 15:29 UnlockUser.svg</TextBlock>
36+
<TextBlock>-rw-r--r-- 1 jdoe staff 561 27 Jan 15:29 User.svg</TextBlock>
37+
</StackPanel>
38+
</ScrollViewer>
39+
</Border>
40+
<Border Background="{DynamicResource BackgroundBrush}"
41+
BorderBrush="{DynamicResource ControlBorderMidColor}" BorderThickness="1" Width="330"
42+
Height="300">
43+
<ScrollViewer HorizontalScrollBarVisibility="Auto" Padding="5 " AllowAutoHide="False">
44+
<StackPanel Background="{DynamicResource BackgroundBrush}">
45+
<TextBlock>drwxr-xr-x 26 jdoe staff 832 28 Jan 14:27 .</TextBlock>
46+
<TextBlock>drwxr-xr-x@ 17 jdoe staff 544 29 Jan 11:59 ..</TextBlock>
47+
<TextBlock>-rw-r--r--@ 1 jdoe staff 6148 28 Jan 14:27 .DS_Store</TextBlock>
48+
<TextBlock>-rw-r--r-- 1 jdoe staff 534 27 Jan 15:29 Add.svg</TextBlock>
49+
<TextBlock>-rw-r--r-- 1 jdoe staff 506 27 Jan 15:29 AddThin.svg</TextBlock>
50+
<TextBlock>-rw-r--r-- 1 jdoe staff 536 27 Jan 15:29 Computer.svg</TextBlock>
51+
<TextBlock>-rw-r--r-- 1 jdoe staff 909 27 Jan 15:29 CopyHost.svg</TextBlock>
52+
<TextBlock>-rw-r--r-- 1 jdoe staff 795 27 Jan 15:29 CopyName.svg</TextBlock>
53+
<TextBlock>-rw-r--r-- 1 jdoe staff 986 27 Jan 15:29 CopyPassword.svg</TextBlock>
54+
<TextBlock>-rw-r--r-- 1 jdoe staff 1169 27 Jan 15:29 CopyUserName.svg</TextBlock>
55+
<TextBlock>-rw-r--r-- 1 jdoe staff 1189 27 Jan 15:29 CopyUserNamePassword.svg</TextBlock>
56+
<TextBlock>-rw-r--r-- 1 jdoe staff 749 27 Jan 15:29 Details.svg</TextBlock>
57+
<TextBlock>-rw-r--r-- 1 jdoe staff 888 27 Jan 15:29 DisableUser.svg</TextBlock>
58+
<TextBlock>-rw-r--r-- 1 jdoe staff 777 27 Jan 15:29 EnableUser.svg</TextBlock>
59+
<TextBlock>-rw-r--r-- 1 jdoe staff 368 27 Jan 15:29 Folder.svg</TextBlock>
60+
<TextBlock>-rw-r--r-- 1 jdoe staff 880 27 Jan 15:29 Help.svg</TextBlock>
61+
<TextBlock>-rw-r--r-- 1 jdoe staff 488 27 Jan 15:29 HorizontalLine.svg</TextBlock>
62+
<TextBlock>-rw-r--r-- 1 jdoe staff 564 27 Jan 15:29 More.svg</TextBlock>
63+
<TextBlock>-rw-r--r-- 1 jdoe staff 579 27 Jan 15:29 Padlock.svg</TextBlock>
64+
<TextBlock>-rw-r--r-- 1 jdoe staff 715 27 Jan 15:29 PasswordAnalyser.svg</TextBlock>
65+
<TextBlock>-rw-r--r-- 1 jdoe staff 1013 27 Jan 15:29 PrivateKey.svg</TextBlock>
66+
<TextBlock>-rw-r--r-- 1 jdoe staff 1275 27 Jan 15:29 Properties.svg</TextBlock>
67+
<TextBlock>-rw-r--r-- 1 jdoe staff 820 27 Jan 15:29 ResetPassword.svg</TextBlock>
68+
<TextBlock>-rw-r--r--@ 1 jdoe staff 147049 28 Jan 14:27 SampleImage.jpg</TextBlock>
69+
<TextBlock>-rw-r--r-- 1 jdoe staff 729 27 Jan 15:29 UnlockUser.svg</TextBlock>
70+
<TextBlock>-rw-r--r-- 1 jdoe staff 561 27 Jan 15:29 User.svg</TextBlock>
71+
</StackPanel>
72+
</ScrollViewer>
73+
</Border>
74+
</StackPanel>
1975
</Design.PreviewWith>
2076

2177
<ControlTheme x:Key="{x:Type ScrollViewer}" TargetType="ScrollViewer">
@@ -63,9 +119,5 @@
63119
<Style Selector="^[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator">
64120
<Setter Property="Opacity" Value="1" />
65121
</Style>
66-
<Style Selector="^[AllowAutoHide=True] /template/ ScrollContentPresenter#PART_ContentPresenter">
67-
<Setter Property="Grid.ColumnSpan" Value="2" />
68-
<Setter Property="Grid.RowSpan" Value="2" />
69-
</Style>
70122
</ControlTheme>
71123
</ResourceDictionary>

0 commit comments

Comments
 (0)