Skip to content

Commit

Permalink
Merge pull request #1961 from cwensley/curtis/wpf-optimizations
Browse files Browse the repository at this point in the history
Wpf: a few minor optimizations
  • Loading branch information
cwensley committed Jun 4, 2021
2 parents 292da8a + e45b912 commit 73f9df7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/Eto.Wpf/Forms/Controls/TextBoxHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ public string Text
var oldText = Text;
CurrentText = null;
var newText = value ?? string.Empty;
TextBox.BeginChange();
if (newText != oldText)
{
var args = new TextChangingEventArgs(oldText, newText, false);
Expand All @@ -303,6 +304,7 @@ public string Text
TextBox.SelectionStart = value.Length;
TextBox.SelectionLength = 0;
}
TextBox.EndChange();
}
}

Expand Down Expand Up @@ -345,8 +347,10 @@ public Range<int> Selection
set
{
CurrentSelection = null;
TextBox.BeginChange();
TextBox.SelectionStart = value.Start;
TextBox.SelectionLength = value.Length();
TextBox.EndChange();
if (!HasFocus)
initialSelection = true;
}
Expand Down
7 changes: 5 additions & 2 deletions src/Eto.Wpf/Forms/WpfFrameworkElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,11 @@ public virtual bool Visible
get { return ContainerControl.Visibility == sw.Visibility.Visible; }
set
{
ContainerControl.Visibility = (value) ? sw.Visibility.Visible : sw.Visibility.Collapsed;
UpdatePreferredSize();
if (value != Visible)
{
ContainerControl.Visibility = (value) ? sw.Visibility.Visible : sw.Visibility.Collapsed;
UpdatePreferredSize();
}
}
}

Expand Down

0 comments on commit 73f9df7

Please sign in to comment.