Merge pull request #464 from AvaloniaUI/watermark-support
Add watermark support
This commit is contained in:
Коммит
d4a0d382ed
|
@ -51,7 +51,8 @@
|
|||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
FontWeight="Light"
|
||||
FontSize="14" >
|
||||
FontSize="14"
|
||||
Watermark="Start typing to bring your ideas to life...">
|
||||
<AvalonEdit:TextEditor.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Header="Copy" InputGesture="ctrl+C" Command="{Binding CopyMouseCommmand}" CommandParameter="{Binding #Editor.TextArea}"></MenuItem>
|
||||
|
|
|
@ -142,6 +142,24 @@ namespace AvaloniaEdit.Editing
|
|||
|
||||
#endregion
|
||||
|
||||
#region Watermark
|
||||
/// <summary>
|
||||
/// Defines the <see cref="Watermark"/> property
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<string> WatermarkProperty =
|
||||
AvaloniaProperty.Register<TextArea, string>(nameof(Watermark));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the <see cref="Text"/>
|
||||
/// property is not yet set.
|
||||
/// </summary>
|
||||
public string Watermark
|
||||
{
|
||||
get => GetValue(WatermarkProperty);
|
||||
set => SetValue(WatermarkProperty, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="IScrollable.Offset" /> property.
|
||||
/// </summary>
|
||||
|
|
|
@ -20,8 +20,20 @@
|
|||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
<ContentPresenter Name="PART_CP" Cursor="IBeam"
|
||||
Focusable="False" Background="{TemplateBinding Background}" />
|
||||
<Panel>
|
||||
<ContentPresenter Name="PART_CP"
|
||||
Cursor="IBeam"
|
||||
Focusable="False"
|
||||
Background="{TemplateBinding Background}" />
|
||||
<TextBlock Name="PART_Watermark"
|
||||
Opacity="0.5"
|
||||
Text="{TemplateBinding Watermark}"
|
||||
Foreground="{TemplateBinding Foreground}">
|
||||
<TextBlock.IsVisible>
|
||||
<Binding RelativeSource="{RelativeSource TemplatedParent}" Path="Document.Text" Converter="{x:Static StringConverters.IsNullOrEmpty}"/>
|
||||
</TextBlock.IsVisible>
|
||||
</TextBlock>
|
||||
</Panel>
|
||||
</DockPanel>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
|
|
@ -241,6 +241,16 @@ namespace AvaloniaEdit
|
|||
#endregion
|
||||
|
||||
#region Text property
|
||||
/// <summary>
|
||||
/// Gets or sets the placeholder or descriptive text that is displayed even if the <see cref="Text"/>
|
||||
/// property is not yet set.
|
||||
/// </summary>
|
||||
public string Watermark
|
||||
{
|
||||
get => textArea.Watermark;
|
||||
set => textArea.Watermark = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets/Sets the text of the current document.
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче