diff --git a/src/Perspex.Controls/Presenters/ScrollContentPresenter.cs b/src/Perspex.Controls/Presenters/ScrollContentPresenter.cs
index 1e2550e717..d7508f69b6 100644
--- a/src/Perspex.Controls/Presenters/ScrollContentPresenter.cs
+++ b/src/Perspex.Controls/Presenters/ScrollContentPresenter.cs
@@ -45,7 +45,7 @@ namespace Perspex.Controls.Presenters
/// Defines the property.
///
public static readonly StyledProperty CanScrollHorizontallyProperty =
- PerspexProperty.Register("CanScrollHorizontally", true);
+ ScrollViewer.CanScrollHorizontallyProperty.AddOwner();
private Size _extent;
private Size _measuredExtent;
diff --git a/src/Perspex.Controls/ScrollViewer.cs b/src/Perspex.Controls/ScrollViewer.cs
index 7aae3ade09..2c42104af7 100644
--- a/src/Perspex.Controls/ScrollViewer.cs
+++ b/src/Perspex.Controls/ScrollViewer.cs
@@ -17,8 +17,8 @@ namespace Perspex.Controls
///
/// Defines the property.
///
- public static readonly AttachedProperty CanScrollHorizontallyProperty =
- PerspexProperty.RegisterAttached(nameof(CanScrollHorizontally), true);
+ public static readonly StyledProperty CanScrollHorizontallyProperty =
+ PerspexProperty.Register(nameof(CanScrollHorizontally), true);
///
/// Defines the property.
diff --git a/src/Perspex.Controls/TextBox.cs b/src/Perspex.Controls/TextBox.cs
index 2e1bfc1cac..5eb60609c7 100644
--- a/src/Perspex.Controls/TextBox.cs
+++ b/src/Perspex.Controls/TextBox.cs
@@ -26,6 +26,9 @@ namespace Perspex.Controls
public static readonly StyledProperty AcceptsTabProperty =
PerspexProperty.Register("AcceptsTab");
+ public static readonly DirectProperty CanScrollHorizontallyProperty =
+ PerspexProperty.RegisterDirect("CanScrollHorizontally", o => o.CanScrollHorizontally);
+
// TODO: Should CaretIndex, SelectionStart/End and Text be direct properties?
public static readonly StyledProperty CaretIndexProperty =
PerspexProperty.Register("CaretIndex", validate: ValidateCaretIndex);
@@ -68,6 +71,7 @@ namespace Perspex.Controls
public bool Equals(UndoRedoState other) => ReferenceEquals(Text, other.Text) || Equals(Text, other.Text);
}
+ private bool _canScrollHorizontally;
private TextPresenter _presenter;
private UndoRedoHelper _undoRedoHelper;
@@ -80,12 +84,8 @@ namespace Perspex.Controls
public TextBox()
{
var canScrollHorizontally = this.GetObservable(TextWrappingProperty)
- .Select(x => x == TextWrapping.NoWrap);
-
- Bind(
- ScrollViewer.CanScrollHorizontallyProperty,
- canScrollHorizontally,
- BindingPriority.Style);
+ .Select(x => x == TextWrapping.NoWrap)
+ .Subscribe(x => CanScrollHorizontally = x);
var horizontalScrollBarVisibility = this.GetObservable(AcceptsReturnProperty)
.Select(x => x ? ScrollBarVisibility.Auto : ScrollBarVisibility.Hidden);
@@ -109,6 +109,12 @@ namespace Perspex.Controls
set { SetValue(AcceptsTabProperty, value); }
}
+ public bool CanScrollHorizontally
+ {
+ get { return _canScrollHorizontally; }
+ private set { SetAndRaise(CanScrollHorizontallyProperty, ref _canScrollHorizontally, value); }
+ }
+
public int CaretIndex
{
get { return GetValue(CaretIndexProperty); }
diff --git a/src/Perspex.Themes.Default/TextBox.xaml b/src/Perspex.Themes.Default/TextBox.xaml
index 26943f6f86..a62c2f406a 100644
--- a/src/Perspex.Themes.Default/TextBox.xaml
+++ b/src/Perspex.Themes.Default/TextBox.xaml
@@ -28,7 +28,7 @@
-