Browse Source

MultiLineTextEditor: added text releated properties

pull/1645/head
brianlagunas_cp 15 years ago
parent
commit
72ec92e4c2
  1. 64
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MultiLineTextEditor/Implementation/MultiLineTextEditor.cs
  2. 11
      ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MultiLineTextEditor/Themes/Generic.xaml

64
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MultiLineTextEditor/Implementation/MultiLineTextEditor.cs

@ -10,13 +10,26 @@ namespace Microsoft.Windows.Controls
{
#region Members
TextBox _textBox;
Thumb _resizeThumb;
#endregion //Members
#region Properties
public static readonly DependencyProperty DropDownHeightProperty = DependencyProperty.Register("DropDownHeight", typeof(double), typeof(MultiLineTextEditor), new UIPropertyMetadata(150.0));
public double DropDownHeight
{
get { return (double)GetValue(DropDownHeightProperty); }
set { SetValue(DropDownHeightProperty, value); }
}
public static readonly DependencyProperty DropDownWidthProperty = DependencyProperty.Register("DropDownWidth", typeof(double), typeof(MultiLineTextEditor), new UIPropertyMetadata(200.0));
public double DropDownWidth
{
get { return (double)GetValue(DropDownWidthProperty); }
set { SetValue(DropDownWidthProperty, value); }
}
#region IsOpen
public static readonly DependencyProperty IsOpenProperty = DependencyProperty.Register("IsOpen", typeof(bool), typeof(MultiLineTextEditor), new UIPropertyMetadata(false, OnIsOpenChanged));
@ -40,6 +53,14 @@ namespace Microsoft.Windows.Controls
#endregion //IsOpen
public static readonly DependencyProperty IsSpellCheckEnabledProperty = DependencyProperty.Register("IsSpellCheckEnabled", typeof(bool), typeof(MultiLineTextEditor), new UIPropertyMetadata(false));
public bool IsSpellCheckEnabled
{
get { return (bool)GetValue(IsSpellCheckEnabledProperty); }
set { SetValue(IsSpellCheckEnabledProperty, value); }
}
#region Text
public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(MultiLineTextEditor), new FrameworkPropertyMetadata(String.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnTextChanged));
@ -63,6 +84,21 @@ namespace Microsoft.Windows.Controls
#endregion //Text
public static readonly DependencyProperty TextAlignmentProperty = DependencyProperty.Register("TextAlignment", typeof(TextAlignment), typeof(MultiLineTextEditor), new UIPropertyMetadata(TextAlignment.Left));
public TextAlignment TextAlignment
{
get { return (TextAlignment)GetValue(TextAlignmentProperty); }
set { SetValue(TextAlignmentProperty, value); }
}
public static readonly DependencyProperty TextWrappingProperty = DependencyProperty.Register("TextWrapping", typeof(TextWrapping), typeof(MultiLineTextEditor), new UIPropertyMetadata(TextWrapping.NoWrap));
public TextWrapping TextWrapping
{
get { return (TextWrapping)GetValue(TextWrappingProperty); }
set { SetValue(TextWrappingProperty, value); }
}
#endregion //Properties
#region Constructors
@ -86,8 +122,6 @@ namespace Microsoft.Windows.Controls
{
base.OnApplyTemplate();
_textBox = (TextBox)GetTemplateChild("PART_TextBox");
if (_resizeThumb != null)
_resizeThumb.DragDelta -= ResizeThumb_DragDelta;
_resizeThumb = (Thumb)GetTemplateChild("PART_ResizeThumb");
@ -97,18 +131,6 @@ namespace Microsoft.Windows.Controls
}
void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
double yadjust = this._textBox.Height + e.VerticalChange;
double xadjust = this._textBox.Width + e.HorizontalChange;
if ((xadjust >= 0) && (yadjust >= 0))
{
this._textBox.Width = xadjust;
this._textBox.Height = yadjust;
}
}
#endregion //Bass Class Overrides
#region Event Handlers
@ -131,6 +153,18 @@ namespace Microsoft.Windows.Controls
CloseEditor();
}
void ResizeThumb_DragDelta(object sender, DragDeltaEventArgs e)
{
double yadjust = DropDownHeight + e.VerticalChange;
double xadjust = DropDownWidth + e.HorizontalChange;
if ((xadjust >= 0) && (yadjust >= 0))
{
DropDownWidth = xadjust;
DropDownHeight = yadjust;
}
}
#endregion //Event Handlers
#region Methods

11
ExtendedWPFToolkitSolution/Src/WPFToolkit.Extended/MultiLineTextEditor/Themes/Generic.xaml

@ -96,14 +96,15 @@
IsHitTestVisible="{Binding IsOpen, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBoolConverter}}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/>
<Popup IsOpen="{Binding IsChecked, ElementName=PART_DropDownButton}" StaysOpen="False"
Placement="Bottom" SnapsToDevicePixels="True" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide">
Placement="Bottom" SnapsToDevicePixels="True" AllowsTransparency="True" Focusable="False" PopupAnimation="Slide"
Width="{TemplateBinding DropDownWidth}" Height="{TemplateBinding DropDownHeight}">
<Border BorderThickness="1" Background="{StaticResource PopupBackgroundBrush}" BorderBrush="{StaticResource PopupDarkBorderBrush}">
<Grid>
<TextBox x:Name="PART_TextBox" AcceptsReturn="true" TextWrapping="NoWrap" Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
Width="200" Height="150"
<TextBox x:Name="PART_TextBox" AcceptsReturn="true" TextWrapping="{TemplateBinding TextWrapping}" Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
SpellCheck.IsEnabled="{TemplateBinding IsSpellCheckEnabled}"
Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}"
Margin="3">
</TextBox>
TextAlignment="{TemplateBinding TextAlignment}"
Margin="3" />
<Thumb x:Name="PART_ResizeThumb" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE">
<Thumb.Template>
<ControlTemplate TargetType="{x:Type Thumb}">

Loading…
Cancel
Save