avalonedit 컨트롤을 사용하는 사용자 정의 컨트롤을 만들었습니다. 사용자 컨트롤의 XAML은 다음과 같습니다ScrollViewer가 Avalonedit을 사용하여 아래로 스크롤하지 않음
<UserControl x:Class="CodeNote.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:editing="clr-namespace:ICSharpCode.AvalonEdit.Editing">
<UserControl.Resources>
<ControlTemplate x:Key="TextBoxBaseControlTemplate1" TargetType="{x:Type TextBoxBase}">
<Border Background="{TemplateBinding Background}"
x:Name="Bd" BorderBrush="#D1D1E8"
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="10, 10, 0, 0">
<ScrollViewer x:Name="PART_ContentHost"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" TargetName="Bd"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
<Trigger Property="Width" Value="Auto">
<Setter Property="MinWidth" Value="100"/>
</Trigger>
<Trigger Property="Height" Value="Auto">
<Setter Property="MinHeight" Value="20"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</UserControl.Resources>
<Grid>
<StackPanel Margin="0,0,0,10">
<TextBox x:Name="txtTitle" VerticalContentAlignment="Center" Template="{StaticResource TextBoxBaseControlTemplate1}" FontWeight="Bold" Margin="5,5,5,0" Padding="5, 3, 5, 2" FontFamily="Arial" FontSize="12" BorderThickness="1,1,1,0" Background="#FFF0F0F0"></TextBox>
<Border BorderThickness="1" CornerRadius="0,0,10,10" BorderBrush="#D1D1E8" Background="#FFF7F7F9" Margin="5,0,5,0" Padding="5,5,5,5">
<avalonEdit:TextEditor
xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
Name="textEditor"
FontFamily="Courier New"
SyntaxHighlighting="Java"
Background="#FFF7F7F9"
ShowLineNumbers="True"
VerticalScrollBarVisibility="Hidden"
HorizontalScrollBarVisibility ="Hidden"
WordWrap="True"
FontSize="12pt"/>
</Border>
</StackPanel>
</Grid>
</UserControl>
메인 윈도우는 사용자가 프로그램 메인 창에 해당 UserControl을 추가 할 수 있어야
<Window x:Class="CodeNote.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
xmlns:editing="clr-namespace:ICSharpCode.AvalonEdit.Editing"
x:Name="mainWin"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollBarVisibility="Visible" CanContentScroll="False">
<StackPanel Grid.Row="0" Margin="10,10,10,0" VerticalAlignment="Top" x:Name="container">
</StackPanel>
</ScrollViewer>
</Grid>
</Window>
그리드 내에서 ScrollViewer 내에서 다음 StackPanel에 포함 어떤이와 뒤에 메인 창 코드에서 수행됩니다
UserControl1 avEditor = new UserControl1(); container.Children.Add(avEditor);
내 문제 것은있는 ScrollView이다 어 버치 네트 컨트롤의 내용이 윈도우에 비해 너무 수직적으로 커지게되면 하단으로 스크롤되지 않습니다. 삽입 지점은 보이는 창 아래쪽에서 사라지고 스크롤 위치는 맨 위에 유지됩니다.
avalonedit 컨트롤 대신 일반 텍스트 상자를 추가하면 스크롤이 올바르게 작동합니다.
나는
프로그램이 다음 텍스트 상자 다음에이 스크롤 뷰어, 예를 들어 avalonedit에 여러 텍스트 입력 컨트롤을 추가 할 수 있어야 있습니다 (I는 WPF에 아주 새로운 오전)이을 해결할 수있는 방법 또 다른 텍스트 상자 다음에 다른 avalonedit이옵니다. 따라서 편집중인 컨트롤이 scrollviewer의 마지막 컨트롤이 아니기 때문에 scrollviewer의 ScrollToBottom 메서드를 사용할 수 없습니다.
화면 상에 표시하려면 삽입 점을, 그에 따라 스크롤 할 창만 있으면됩니다.