Auto scroll when text changed or selection changed in a TextBox

This commit is contained in:
leo 2020-07-12 22:24:59 +08:00
parent 4cb2568385
commit bd96a9709f
5 changed files with 360 additions and 279 deletions

View file

@ -1,143 +1,225 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Input;
using System.Windows.Media;
namespace SourceGit.Helpers {
namespace SourceGit.Helpers {
/// <summary>
/// Attached properties to TextBox. /// <summary>
/// </summary> /// Attached properties to TextBox.
public static class TextBoxHelper { /// </summary>
public static class TextBoxHelper {
/// <summary>
/// Placeholder property /// <summary>
/// </summary> /// Auto scroll on text changed.
public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached( /// </summary>
"Placeholder", public static readonly DependencyProperty AutoScrollProperty = DependencyProperty.RegisterAttached(
typeof(string), "AutoScroll",
typeof(TextBoxHelper), typeof(bool),
new PropertyMetadata(string.Empty, OnPlaceholderChanged)); typeof(TextBoxHelper),
new PropertyMetadata(false, OnAutoScrollChanged));
/// <summary>
/// Vertical alignment for placeholder. /// <summary>
/// </summary> /// Placeholder property
public static readonly DependencyProperty PlaceholderBaselineProperty = DependencyProperty.RegisterAttached( /// </summary>
"PlaceholderBaseline", public static readonly DependencyProperty PlaceholderProperty = DependencyProperty.RegisterAttached(
typeof(AlignmentY), "Placeholder",
typeof(TextBoxHelper), typeof(string),
new PropertyMetadata(AlignmentY.Center)); typeof(TextBoxHelper),
new PropertyMetadata(string.Empty, OnPlaceholderChanged));
/// <summary>
/// Property to store generated placeholder brush. /// <summary>
/// </summary> /// Vertical alignment for placeholder.
public static readonly DependencyProperty PlaceholderBrushProperty = DependencyProperty.RegisterAttached( /// </summary>
"PlaceholderBrush", public static readonly DependencyProperty PlaceholderBaselineProperty = DependencyProperty.RegisterAttached(
typeof(Brush), "PlaceholderBaseline",
typeof(TextBoxHelper), typeof(AlignmentY),
new PropertyMetadata(Brushes.Transparent)); typeof(TextBoxHelper),
new PropertyMetadata(AlignmentY.Center));
/// <summary>
/// Triggered when placeholder changed. /// <summary>
/// </summary> /// Property to store generated placeholder brush.
/// <param name="d"></param> /// </summary>
/// <param name="e"></param> public static readonly DependencyProperty PlaceholderBrushProperty = DependencyProperty.RegisterAttached(
private static void OnPlaceholderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { "PlaceholderBrush",
var textBox = d as TextBox; typeof(Brush),
if (textBox != null) textBox.Loaded += OnTextLoaded; typeof(TextBoxHelper),
} new PropertyMetadata(Brushes.Transparent));
/// <summary> /// <summary>
/// Setter for Placeholder property /// Setter for AutoScrollProperty
/// </summary> /// </summary>
/// <param name="element"></param> /// <param name="element"></param>
/// <param name="value"></param> /// <param name="enabled"></param>
public static void SetPlaceholder(UIElement element, string value) { public static void SetAutoScroll(UIElement element, bool enabled) {
element.SetValue(PlaceholderProperty, value); element.SetValue(AutoScrollProperty, enabled);
} }
/// <summary> /// <summary>
/// Getter for Placeholder property /// Getter for AutoScrollProperty
/// </summary> /// </summary>
/// <param name="element"></param> /// <param name="element"></param>
/// <returns></returns> /// <returns></returns>
public static string GetPlaceholder(UIElement element) { public static bool GetAutoScroll(UIElement element) {
return (string)element.GetValue(PlaceholderProperty); return (bool)element.GetValue(AutoScrollProperty);
} }
/// <summary> /// <summary>
/// Setter for PlaceholderBaseline property /// Triggered when AutoScroll property changed.
/// </summary> /// </summary>
/// <param name="element"></param> /// <param name="d"></param>
/// <param name="align"></param> /// <param name="e"></param>
public static void SetPlaceholderBaseline(UIElement element, AlignmentY align) { public static void OnAutoScrollChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
element.SetValue(PlaceholderBaselineProperty, align); var textBox = d as TextBox;
} if (textBox == null) return;
/// <summary> textBox.SelectionChanged -= UpdateScrollOnSelectionChanged;
/// Setter for PlaceholderBaseline property. if ((bool)e.NewValue == true) {
/// </summary> textBox.SelectionChanged += UpdateScrollOnSelectionChanged;
/// <param name="element"></param> }
/// <returns></returns> }
public static AlignmentY GetPlaceholderBaseline(UIElement element) {
return (AlignmentY)element.GetValue(PlaceholderBaselineProperty); /// <summary>
} /// Triggered when placeholder changed.
/// </summary>
/// <summary> /// <param name="d"></param>
/// Setter for PlaceholderBrush property. /// <param name="e"></param>
/// </summary> private static void OnPlaceholderChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {
/// <param name="element"></param> var textBox = d as TextBox;
/// <param name="value"></param> if (textBox != null) textBox.Loaded += OnTextLoaded;
public static void SetPlaceholderBrush(UIElement element, Brush value) { }
element.SetValue(PlaceholderBrushProperty, value);
} /// <summary>
/// Setter for Placeholder property
/// <summary> /// </summary>
/// Getter for PlaceholderBrush property. /// <param name="element"></param>
/// </summary> /// <param name="value"></param>
/// <param name="element"></param> public static void SetPlaceholder(UIElement element, string value) {
/// <returns></returns> element.SetValue(PlaceholderProperty, value);
public static Brush GetPlaceholderBrush(UIElement element) { }
return (Brush)element.GetValue(PlaceholderBrushProperty);
} /// <summary>
/// Getter for Placeholder property
/// <summary> /// </summary>
/// Set placeholder as background when TextBox was loaded. /// <param name="element"></param>
/// </summary> /// <returns></returns>
/// <param name="sender"></param> public static string GetPlaceholder(UIElement element) {
/// <param name="e"></param> return (string)element.GetValue(PlaceholderProperty);
private static void OnTextLoaded(object sender, RoutedEventArgs e) { }
var textBox = sender as TextBox;
if (textBox == null) return; /// <summary>
/// Setter for PlaceholderBaseline property
Label placeholder = new Label(); /// </summary>
placeholder.Content = textBox.GetValue(PlaceholderProperty); /// <param name="element"></param>
/// <param name="align"></param>
VisualBrush brush = new VisualBrush(); public static void SetPlaceholderBaseline(UIElement element, AlignmentY align) {
brush.AlignmentX = AlignmentX.Left; element.SetValue(PlaceholderBaselineProperty, align);
brush.AlignmentY = GetPlaceholderBaseline(textBox); }
brush.TileMode = TileMode.None;
brush.Stretch = Stretch.None; /// <summary>
brush.Opacity = 0.3; /// Setter for PlaceholderBaseline property.
brush.Visual = placeholder; /// </summary>
/// <param name="element"></param>
textBox.SetValue(PlaceholderBrushProperty, brush); /// <returns></returns>
textBox.Background = brush; public static AlignmentY GetPlaceholderBaseline(UIElement element) {
textBox.TextChanged += OnTextChanged; return (AlignmentY)element.GetValue(PlaceholderBaselineProperty);
OnTextChanged(textBox, null); }
}
/// <summary>
/// <summary> /// Setter for PlaceholderBrush property.
/// Dynamically hide/show placeholder. /// </summary>
/// </summary> /// <param name="element"></param>
/// <param name="sender"></param> /// <param name="value"></param>
/// <param name="e"></param> public static void SetPlaceholderBrush(UIElement element, Brush value) {
private static void OnTextChanged(object sender, RoutedEventArgs e) { element.SetValue(PlaceholderBrushProperty, value);
var textBox = sender as TextBox; }
if (string.IsNullOrEmpty(textBox.Text)) {
textBox.Background = textBox.GetValue(PlaceholderBrushProperty) as Brush; /// <summary>
} else { /// Getter for PlaceholderBrush property.
textBox.Background = Brushes.Transparent; /// </summary>
} /// <param name="element"></param>
} /// <returns></returns>
} public static Brush GetPlaceholderBrush(UIElement element) {
} return (Brush)element.GetValue(PlaceholderBrushProperty);
}
/// <summary>
/// Set placeholder as background when TextBox was loaded.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void OnTextLoaded(object sender, RoutedEventArgs e) {
var textBox = sender as TextBox;
if (textBox == null) return;
Label placeholder = new Label();
placeholder.Content = textBox.GetValue(PlaceholderProperty);
VisualBrush brush = new VisualBrush();
brush.AlignmentX = AlignmentX.Left;
brush.AlignmentY = GetPlaceholderBaseline(textBox);
brush.TileMode = TileMode.None;
brush.Stretch = Stretch.None;
brush.Opacity = 0.3;
brush.Visual = placeholder;
textBox.SetValue(PlaceholderBrushProperty, brush);
textBox.Background = brush;
textBox.TextChanged += UpdatePlaceholder;
UpdatePlaceholder(textBox, null);
}
/// <summary>
/// Dynamically hide/show placeholder.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void UpdatePlaceholder(object sender, RoutedEventArgs e) {
var textBox = sender as TextBox;
if (string.IsNullOrEmpty(textBox.Text)) {
textBox.Background = textBox.GetValue(PlaceholderBrushProperty) as Brush;
} else {
textBox.Background = Brushes.Transparent;
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private static void UpdateScrollOnSelectionChanged(object sender, RoutedEventArgs e) {
var textBox = sender as TextBox;
if (textBox != null && textBox.IsFocused) {
if (Mouse.LeftButton == MouseButtonState.Pressed && textBox.SelectionLength > 0) {
var p = Mouse.GetPosition(textBox);
if (p.X <= 8) {
textBox.LineLeft();
} else if (p.X >= textBox.ActualWidth - 8) {
textBox.LineRight();
}
if (p.Y <= 8) {
textBox.LineUp();
} else if (p.Y >= textBox.ActualHeight - 8) {
textBox.LineDown();
}
} else {
var rect = textBox.GetRectFromCharacterIndex(textBox.CaretIndex);
if (rect.Left <= 0) {
textBox.ScrollToHorizontalOffset(textBox.HorizontalOffset + rect.Left);
} else if (rect.Right >= textBox.ActualWidth) {
textBox.ScrollToHorizontalOffset(textBox.HorizontalOffset + rect.Right);
}
if (rect.Top <= 0) {
textBox.ScrollToVerticalOffset(textBox.VerticalOffset + rect.Top);
} else if (rect.Bottom >= textBox.ActualHeight) {
textBox.ScrollToVerticalOffset(textBox.VerticalOffset + rect.Bottom);
}
}
}
}
}
}

View file

@ -1,114 +1,118 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<!-- 错误Tooltip --> xmlns:helpers="clr-namespace:SourceGit.Helpers">
<ControlTemplate x:Key="Template.Validation.Tooltip" TargetType="{x:Type ToolTip}">
<Border x:Name="Root" Margin="5,0,0,0" Opacity="0" Padding="0,0,20,20" RenderTransformOrigin="0,0"> <!-- 错误Tooltip -->
<Border.RenderTransform> <ControlTemplate x:Key="Template.Validation.Tooltip" TargetType="{x:Type ToolTip}">
<TranslateTransform x:Name="xform" X="-25" /> <Border x:Name="Root" Margin="5,0,0,0" Opacity="0" Padding="0,0,20,20" RenderTransformOrigin="0,0">
</Border.RenderTransform> <Border.RenderTransform>
<VisualStateManager.VisualStateGroups> <TranslateTransform x:Name="xform" X="-25" />
<VisualStateGroup x:Name="OpenStates"> </Border.RenderTransform>
<VisualStateGroup.Transitions> <VisualStateManager.VisualStateGroups>
<VisualTransition GeneratedDuration="0" /> <VisualStateGroup x:Name="OpenStates">
<VisualTransition GeneratedDuration="0:0:0.2" To="Open"> <VisualStateGroup.Transitions>
<Storyboard> <VisualTransition GeneratedDuration="0" />
<DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform"> <VisualTransition GeneratedDuration="0:0:0.2" To="Open">
<DoubleAnimation.EasingFunction> <Storyboard>
<BackEase Amplitude=".3" EasingMode="EaseOut" /> <DoubleAnimation Duration="0:0:0.2" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform">
</DoubleAnimation.EasingFunction> <DoubleAnimation.EasingFunction>
</DoubleAnimation> <BackEase Amplitude=".3" EasingMode="EaseOut" />
<DoubleAnimation Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" /> </DoubleAnimation.EasingFunction>
</Storyboard> </DoubleAnimation>
</VisualTransition> <DoubleAnimation Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" />
</VisualStateGroup.Transitions> </Storyboard>
<VisualState x:Name="Closed"> </VisualTransition>
<Storyboard> </VisualStateGroup.Transitions>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" /> <VisualState x:Name="Closed">
</Storyboard> <Storyboard>
</VisualState> <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" />
<VisualState x:Name="Open"> </Storyboard>
<Storyboard> </VisualState>
<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform" /> <VisualState x:Name="Open">
<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" /> <Storyboard>
</Storyboard> <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="X" Storyboard.TargetName="xform" />
</VisualState> <DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="Root" />
</VisualStateGroup> </Storyboard>
</VisualStateManager.VisualStateGroups> </VisualState>
<FrameworkElement.Effect> </VisualStateGroup>
<DropShadowEffect BlurRadius="11" ShadowDepth="6" Opacity="0.4" /> </VisualStateManager.VisualStateGroups>
</FrameworkElement.Effect> <FrameworkElement.Effect>
<Border Background="#FFDC000C" BorderThickness="1" BorderBrush="#FFBC000C"> <DropShadowEffect BlurRadius="11" ShadowDepth="6" Opacity="0.4" />
<TextBlock Foreground="White" MaxWidth="250" Margin="8,4,8,4" TextWrapping="Wrap" Text="{Binding [0].ErrorContent}" UseLayoutRounding="false" /> </FrameworkElement.Effect>
</Border> <Border Background="#FFDC000C" BorderThickness="1" BorderBrush="#FFBC000C">
</Border> <TextBlock Foreground="White" MaxWidth="250" Margin="8,4,8,4" TextWrapping="Wrap" Text="{Binding [0].ErrorContent}" UseLayoutRounding="false" />
</ControlTemplate> </Border>
</Border>
<!-- 验证错误模板 --> </ControlTemplate>
<ControlTemplate x:Key="Template.Validation.Error">
<AdornedElementPlaceholder x:Name="Target"> <!-- 验证错误模板 -->
<Border BorderBrush="#FFDB000C" BorderThickness="1" x:Name="root"> <ControlTemplate x:Key="Template.Validation.Error">
<ToolTipService.ToolTip> <AdornedElementPlaceholder x:Name="Target">
<ToolTip x:Name="validationTooltip" <Border BorderBrush="#FFDB000C" BorderThickness="1" x:Name="root">
Placement="Right" <ToolTipService.ToolTip>
PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}" <ToolTip x:Name="validationTooltip"
Template="{StaticResource Template.Validation.Tooltip}" Placement="Right"
Style="{x:Null}"/> PlacementTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
</ToolTipService.ToolTip> Template="{StaticResource Template.Validation.Tooltip}"
<Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Width="12" Margin="1,-4,-4,0" VerticalAlignment="Top"> Style="{x:Null}"/>
<Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C" Margin="1,3,0,0" /> </ToolTipService.ToolTip>
</Grid> <Grid Background="Transparent" HorizontalAlignment="Right" Height="12" Width="12" Margin="1,-4,-4,0" VerticalAlignment="Top">
</Border> <Path Data="M 1,0 L6,0 A 2,2 90 0 1 8,2 L8,7 z" Fill="#FFDC000C" Margin="1,3,0,0" />
</AdornedElementPlaceholder> </Grid>
</Border>
<ControlTemplate.Triggers> </AdornedElementPlaceholder>
<MultiDataTrigger>
<MultiDataTrigger.Conditions> <ControlTemplate.Triggers>
<Condition Binding="{Binding ElementName=Target, Path=AdornedElement.IsKeyboardFocusWithin, Mode=OneWay}" Value="True" /> <MultiDataTrigger>
<Condition Binding="{Binding ElementName=Target, Path=AdornedElement.(Validation.HasError), Mode=OneWay}" Value="True" /> <MultiDataTrigger.Conditions>
</MultiDataTrigger.Conditions> <Condition Binding="{Binding ElementName=Target, Path=AdornedElement.IsKeyboardFocusWithin, Mode=OneWay}" Value="True" />
<Setter TargetName="validationTooltip" Property="IsOpen" Value="True"/> <Condition Binding="{Binding ElementName=Target, Path=AdornedElement.(Validation.HasError), Mode=OneWay}" Value="True" />
</MultiDataTrigger> </MultiDataTrigger.Conditions>
</ControlTemplate.Triggers> <Setter TargetName="validationTooltip" Property="IsOpen" Value="True"/>
</ControlTemplate> </MultiDataTrigger>
</ControlTemplate.Triggers>
<!-- 修改默认 --> </ControlTemplate>
<Style TargetType="{x:Type TextBox}">
<Setter Property="SnapsToDevicePixels" Value="True"/> <!-- 修改默认 -->
<Setter Property="VerticalAlignment" Value="Center"/> <Style TargetType="{x:Type TextBox}">
<Setter Property="VerticalContentAlignment" Value="Center"/> <Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.FG}"/> <Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="CaretBrush" Value="{DynamicResource Brush.FG}"/> <Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Background" Value="Transparent"/> <Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.FG}"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border1}"/> <Setter Property="CaretBrush" Value="{DynamicResource Brush.FG}"/>
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource Template.Validation.Error}"/> <Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border1}"/>
<Setter Property="Template"> <Setter Property="Validation.ErrorTemplate" Value="{StaticResource Template.Validation.Error}"/>
<Setter.Value> <Setter Property="helpers:TextBoxHelper.AutoScroll" Value="True"/>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="Border" <Setter Property="Template">
Background="{TemplateBinding Background}" <Setter.Value>
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" <ControlTemplate TargetType="{x:Type TextBox}">
BorderThickness="{TemplateBinding BorderThickness}" <Border x:Name="Border"
BorderBrush="{TemplateBinding BorderBrush}"> Background="{TemplateBinding Background}"
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
Margin="{TemplateBinding Padding}" BorderThickness="{TemplateBinding BorderThickness}"
VerticalAlignment="Center" BorderBrush="{TemplateBinding BorderBrush}">
Background="{x:Null}" <ScrollViewer x:Name="PART_ContentHost"
BorderThickness="0" Margin="{TemplateBinding Padding}"
IsTabStop="False" VerticalAlignment="Center"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> Background="Transparent"
</Border> BorderThickness="0"
IsTabStop="False"
<ControlTemplate.Triggers> CanContentScroll="False"
<Trigger Property="IsMouseOver" Value="true"> SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
<Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Brush.Accent1}"/> </Border>
</Trigger>
<Trigger Property="AcceptsReturn" Value="True"> <ControlTemplate.Triggers>
<Setter TargetName="PART_ContentHost" Property="VerticalAlignment" Value="Top"/> <Trigger Property="IsMouseOver" Value="true">
</Trigger> <Setter TargetName="Border" Property="BorderBrush" Value="{DynamicResource Brush.Accent1}"/>
</ControlTemplate.Triggers> </Trigger>
</ControlTemplate> <Trigger Property="AcceptsReturn" Value="True">
</Setter.Value> <Setter TargetName="PART_ContentHost" Property="VerticalAlignment" Value="Top"/>
</Setter> </Trigger>
</Style> </ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> </ResourceDictionary>

View file

@ -1,18 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"> <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net461</TargetFramework> <TargetFramework>net46</TargetFramework>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<UseWPF>true</UseWPF> <UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms> <UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>App.ico</ApplicationIcon> <ApplicationIcon>App.ico</ApplicationIcon>
<Company>sourcegit</Company> <Company>sourcegit</Company>
<Description>OpenSource GIT client for Windows</Description> <Description>OpenSource GIT client for Windows</Description>
<Copyright>Copyright © sourcegit 2020. All rights reserved.</Copyright> <Copyright>Copyright © sourcegit 2020. All rights reserved.</Copyright>
<ApplicationManifest>App.manifest</ApplicationManifest> <ApplicationManifest>App.manifest</ApplicationManifest>
<Version>2.0.0-preview</Version> <Version>2.0.0-preview</Version>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Resource Include="App.ico" /> <Resource Include="App.ico" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View file

@ -343,8 +343,7 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
helpers:TextBoxHelper.Placeholder="Enter commit message" helpers:TextBoxHelper.Placeholder="Enter commit message"
helpers:TextBoxHelper.PlaceholderBaseline="Top" helpers:TextBoxHelper.PlaceholderBaseline="Top">
TextChanged="CommitMessageChanged">
<TextBox.Text> <TextBox.Text>
<Binding ElementName="me" Path="CommitMessage" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"> <Binding ElementName="me" Path="CommitMessage" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules> <Binding.ValidationRules>

View file

@ -729,10 +729,6 @@ namespace SourceGit.UI {
e.Handled = true; e.Handled = true;
} }
private void CommitMessageChanged(object sender, TextChangedEventArgs e) {
(sender as TextBox).ScrollToEnd();
}
private void StartAmend(object sender, RoutedEventArgs e) { private void StartAmend(object sender, RoutedEventArgs e) {
var commits = Repo.Commits("-n 1"); var commits = Repo.Commits("-n 1");
if (commits.Count == 0) { if (commits.Count == 0) {