feat: add option to make it selectable.
This commit is contained in:
@@ -19,5 +19,13 @@
|
|||||||
FontSize="30"
|
FontSize="30"
|
||||||
StringFormat="yyyy-MM-dd"
|
StringFormat="yyyy-MM-dd"
|
||||||
Value="{Binding DateValue}" />
|
Value="{Binding DateValue}" />
|
||||||
|
<TextBlock Text="Selectable: "></TextBlock>
|
||||||
|
<u:Int32Displayer Value="{Binding Value}" IsSelectable="True" />
|
||||||
|
<u:DoubleDisplayer StringFormat="N2" Value="{Binding DoubleValue}" IsSelectable="True" />
|
||||||
|
<u:DateDisplay
|
||||||
|
FontSize="30"
|
||||||
|
StringFormat="yyyy-MM-dd"
|
||||||
|
IsSelectable="True"
|
||||||
|
Value="{Binding DateValue}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -16,9 +16,23 @@
|
|||||||
FontWeight="{TemplateBinding FontWeight}"
|
FontWeight="{TemplateBinding FontWeight}"
|
||||||
FontStyle="{TemplateBinding FontSize}"
|
FontStyle="{TemplateBinding FontSize}"
|
||||||
FontStretch="{TemplateBinding FontStretch}"
|
FontStretch="{TemplateBinding FontStretch}"
|
||||||
Text="{TemplateBinding InternalText,
|
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
||||||
Mode=OneWay}" />
|
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
<Style Selector="^[IsSelectable=True]">
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:NumberDisplayerBase">
|
||||||
|
<SelectableTextBlock
|
||||||
|
FontSize="{TemplateBinding FontSize}"
|
||||||
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
FontFamily="{TemplateBinding FontFamily}"
|
||||||
|
Background="{TemplateBinding Background}"
|
||||||
|
FontWeight="{TemplateBinding FontWeight}"
|
||||||
|
FontStyle="{TemplateBinding FontSize}"
|
||||||
|
FontStretch="{TemplateBinding FontStretch}"
|
||||||
|
Text="{TemplateBinding InternalText, Mode=OneWay}" />
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|||||||
@@ -35,6 +35,15 @@ public abstract class NumberDisplayerBase : TemplatedControl
|
|||||||
get => GetValue(StringFormatProperty);
|
get => GetValue(StringFormatProperty);
|
||||||
set => SetValue(StringFormatProperty, value);
|
set => SetValue(StringFormatProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> IsSelectableProperty = AvaloniaProperty.Register<NumberDisplayerBase, bool>(
|
||||||
|
nameof(IsSelectable));
|
||||||
|
|
||||||
|
public bool IsSelectable
|
||||||
|
{
|
||||||
|
get => GetValue(IsSelectableProperty);
|
||||||
|
set => SetValue(IsSelectableProperty, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class NumberDisplayer<T>: NumberDisplayerBase
|
public abstract class NumberDisplayer<T>: NumberDisplayerBase
|
||||||
|
|||||||
Reference in New Issue
Block a user