Skip to content

Commit fca305d

Browse files
Merge pull request #84 from atc-net/feature/LabelControl-InformationContent
feat: Add InformationContent property to LabelControl
2 parents 170b687 + 8e907b2 commit fca305d

34 files changed

+122
-22
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
<ItemGroup Label="Code Analyzers">
4848
<PackageReference Include="AsyncFixer" Version="1.6.0" PrivateAssets="All" />
4949
<PackageReference Include="Asyncify" Version="0.9.7" PrivateAssets="All" />
50-
<PackageReference Include="Meziantou.Analyzer" Version="2.0.98" PrivateAssets="All" />
50+
<PackageReference Include="Meziantou.Analyzer" Version="2.0.104" PrivateAssets="All" />
5151
<PackageReference Include="SecurityCodeScan.VS2019" Version="5.6.7" PrivateAssets="All" />
5252
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="All" />
5353
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.12.0.78982" PrivateAssets="All" />

sample/Atc.Wpf.Sample/Atc.Wpf.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</ItemGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="Atc" Version="2.0.380" />
27+
<PackageReference Include="Atc" Version="2.0.386" />
2828
<PackageReference Include="ControlzEx" Version="6.0.0" />
2929
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0-preview.6.23329.7" />
3030
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0-preview.6.23329.7" />

sample/Atc.Wpf.Sample/SamplesWpfControls/LabelControls/LabelTextBoxView.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,38 @@
8686
<atc:LabelTextBox LabelText="MyLabel3" Orientation="Vertical" />
8787

8888
<atc:LabelTextBox
89+
InformationColor="Green"
8990
InformationText="This is a help text.."
9091
IsMandatory="True"
9192
LabelText="MyLabel4"
9293
Orientation="Vertical"
9394
ShowClearTextButton="True"
9495
WatermarkText="Fill out with text.." />
9596

97+
<atc:LabelTextBox
98+
InformationColor="Chocolate"
99+
InformationContent="This is a help text.."
100+
IsMandatory="True"
101+
LabelText="MyLabel5"
102+
Orientation="Vertical"
103+
ShowClearTextButton="True"
104+
WatermarkText="Fill out with text.." />
105+
106+
<atc:LabelTextBox
107+
IsMandatory="True"
108+
LabelText="MyLabel6"
109+
Orientation="Vertical"
110+
ShowClearTextButton="True"
111+
WatermarkText="Fill out with text..">
112+
<atc:LabelTextBox.InformationContent>
113+
<StackPanel>
114+
<atc:LabelTextInfo LabelText="Info 1" Text="My Info 1" />
115+
<atc:LabelTextInfo LabelText="Info 2" Text="My Info 2" />
116+
<atc:LabelTextInfo LabelText="Info 3" Text="My Info 3" />
117+
</StackPanel>
118+
</atc:LabelTextBox.InformationContent>
119+
</atc:LabelTextBox>
120+
96121
</StackPanel>
97122
</atc:GridEx>
98123
</ScrollViewer>

src/Atc.Wpf.Controls/Atc.Wpf.Controls.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Atc" Version="2.0.380" />
23+
<PackageReference Include="Atc" Version="2.0.386" />
2424
</ItemGroup>
2525

2626
<ItemGroup>

src/Atc.Wpf.Controls/LabelControls/Abstractions/ILabelControlBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public interface ILabelControlBase
2424

2525
string InformationText { get; set; }
2626

27+
object? InformationContent { get; set; }
28+
2729
Color InformationColor { get; set; }
2830

2931
string GetFullIdentifier();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
namespace Atc.Wpf.Controls.LabelControls.Internal.ValueConverters;
2+
3+
internal class LabelControlInformationMultiBoolToVisibilityVisibleValueConverter : IMultiValueConverter
4+
{
5+
/// <inheritdoc />
6+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
7+
{
8+
ArgumentNullException.ThrowIfNull(values);
9+
10+
if (values is not { Length: 3 })
11+
{
12+
return Visibility.Collapsed;
13+
}
14+
15+
var hideAreasIsInformation = values[0] is bool && (bool)values[0];
16+
var informationTextIsNotEmpty = values[1] is bool && (bool)values[1];
17+
var informationContentIsNotNull = values[2] is bool && (bool)values[2];
18+
19+
return hideAreasIsInformation &&
20+
(informationTextIsNotEmpty || informationContentIsNotNull)
21+
? Visibility.Visible
22+
: Visibility.Collapsed;
23+
}
24+
25+
/// <inheritdoc />
26+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
27+
{
28+
throw new NotSupportedException("This is a OneWay converter.");
29+
}
30+
}

src/Atc.Wpf.Controls/LabelControls/LabelCheckBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<labelControls:LabelContent
1111
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1212
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
13+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1314
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1415
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelCheckBox}}, Path=LabelText, FallbackValue=CheckBox}"
1516
LabelWidthNumber="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=LabelWidthNumber}"

src/Atc.Wpf.Controls/LabelControls/LabelComboBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<labelControls:LabelContent
1111
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1212
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
13+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1314
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1415
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
1516
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelComboBox}}, Path=LabelText, FallbackValue=ComboBox}"

src/Atc.Wpf.Controls/LabelControls/LabelContent.xaml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
xmlns:labelControls="clr-namespace:Atc.Wpf.Controls.LabelControls"
99
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1010
xmlns:valueConverters="clr-namespace:Atc.Wpf.Controls.LabelControls.Internal.ValueConverters"
11+
x:Name="Lc"
1112
MinWidth="200"
1213
mc:Ignorable="d">
1314

1415
<labelControls:LabelControl.Resources>
1516
<atcValueConverters:MultiBoolToVisibilityVisibleValueConverter x:Key="MultiBoolToVisibilityVisibleValueConverter" />
17+
<atcValueConverters:IsNotNullValueConverter x:Key="IsNotNullValueConverter" />
1618
<atcValueConverters:StringNullOrEmptyToInverseBoolValueConverter x:Key="StringNullOrEmptyToInverseBoolValueConverter" />
19+
<atcValueConverters:StringNullOrEmptyToVisibilityCollapsedValueConverter x:Key="StringNullOrEmptyToVisibilityCollapsedValueConverter" />
1720
<valueConverters:LabelControlHideAreasForValidationToGridExRowsValueConverter x:Key="LabelControlHideAreasForValidationToGridExRowsValueConverter" />
1821
<valueConverters:LabelControlHideAreasToBoolValueConverter x:Key="LabelControlHideAreasToBoolValueConverter" />
1922
<valueConverters:LabelControlHideAreasToVisibilityValueConverter x:Key="LabelControlHideAreasToVisibilityValueConverter" />
@@ -22,6 +25,7 @@
2225
<valueConverters:LabelControlOrientationToVisibilityValueConverter x:Key="LabelControlOrientationToVisibilityValueConverter" />
2326
<valueConverters:LabelControlOrientationToAsteriskMarginValueConverter x:Key="LabelControlOrientationToAsteriskMarginValueConverter" />
2427
<valueConverters:LabelControlOrientationToInformationIconMarginValueConverter x:Key="LabelControlOrientationToInformationIconMarginValueConverter" />
28+
<valueConverters:LabelControlInformationMultiBoolToVisibilityVisibleValueConverter x:Key="LabelControlInformationMultiBoolToVisibilityVisibleValueConverter" />
2529
</labelControls:LabelControl.Resources>
2630

2731
<labelControls:LabelControl.Style>
@@ -124,19 +128,21 @@
124128
Height="16"
125129
Margin="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Orientation, Converter={StaticResource LabelControlOrientationToInformationIconMarginValueConverter}}"
126130
VerticalAlignment="Top"
127-
OverrideColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor, FallbackValue=DodgerBlue}"
131+
OverrideColor="{Binding ElementName=Lc, Path=InformationColor}"
128132
Source="/Atc.Wpf.Controls;component/Resources/Icons/info_help.svg">
129133
<atc:SvgImage.ToolTip>
130134
<!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
131135
<ToolTip DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}" Style="{StaticResource AtcApps.Styles.ToolTip}">
132-
<StackPanel>
133-
<!-- ReSharper disable once Xaml.BindingWithContextNotResolved -->
134-
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InformationText}" />
136+
<StackPanel Orientation="Vertical">
137+
<!-- ReSharper disable Xaml.BindingWithContextNotResolved -->
138+
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InformationText}" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InformationText, Converter={StaticResource StringNullOrEmptyToVisibilityCollapsedValueConverter}}" />
139+
<ContentControl Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=InformationContent}" />
140+
<!-- ReSharper restore Xaml.BindingWithContextNotResolved -->
135141
</StackPanel>
136142
</ToolTip>
137143
</atc:SvgImage.ToolTip>
138144
<atc:SvgImage.Visibility>
139-
<MultiBinding Converter="{StaticResource MultiBoolToVisibilityVisibleValueConverter}">
145+
<MultiBinding Converter="{StaticResource LabelControlInformationMultiBoolToVisibilityVisibleValueConverter}">
140146
<Binding
141147
Converter="{StaticResource LabelControlHideAreasToBoolValueConverter}"
142148
ConverterParameter="{x:Static labelControls:LabelControlHideAreasType.Information}"
@@ -146,6 +152,10 @@
146152
Converter="{StaticResource StringNullOrEmptyToInverseBoolValueConverter}"
147153
Path="InformationText"
148154
RelativeSource="{RelativeSource AncestorType=UserControl}" />
155+
<Binding
156+
Converter="{StaticResource IsNotNullValueConverter}"
157+
Path="InformationContent"
158+
RelativeSource="{RelativeSource AncestorType=UserControl}" />
149159
</MultiBinding>
150160
</atc:SvgImage.Visibility>
151161
</atc:SvgImage>

src/Atc.Wpf.Controls/LabelControls/LabelControlBase.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ public string InformationText
103103
set => SetValue(InformationTextProperty, value);
104104
}
105105

106+
public static readonly DependencyProperty InformationContentProperty = DependencyProperty.Register(
107+
nameof(InformationContent),
108+
typeof(object),
109+
typeof(LabelControlBase),
110+
new FrameworkPropertyMetadata(
111+
defaultValue: null,
112+
FrameworkPropertyMetadataOptions.AffectsMeasure));
113+
114+
public object? InformationContent
115+
{
116+
get => (object?)GetValue(InformationContentProperty);
117+
set => SetValue(InformationContentProperty, value);
118+
}
119+
106120
public static readonly DependencyProperty InformationColorProperty = DependencyProperty.Register(
107121
nameof(InformationColor),
108122
typeof(Color),

src/Atc.Wpf.Controls/LabelControls/LabelDatePicker.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<labelControls:LabelContent
2020
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
2121
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
22+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
2223
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2324
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2425
IsTabStop="False"

src/Atc.Wpf.Controls/LabelControls/LabelDateTimePicker.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<labelControls:LabelContent
2121
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
2222
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
23+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
2324
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2425
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2526
IsTabStop="False"

src/Atc.Wpf.Controls/LabelControls/LabelDecimalBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<labelControls:LabelContent
1818
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1919
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
20+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
2021
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2122
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2223
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelDecimalBox}}, Path=LabelText, FallbackValue=DecimalBox}"

src/Atc.Wpf.Controls/LabelControls/LabelDecimalXyBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<labelControls:LabelContent
1212
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1313
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
14+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1415
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1516
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
1617
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelDecimalXyBox}}, Path=LabelText, FallbackValue=DecimalXyBox}"

src/Atc.Wpf.Controls/LabelControls/LabelIntegerBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<labelControls:LabelContent
1818
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1919
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
20+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
2021
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2122
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2223
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelIntegerBox}}, Path=LabelText, FallbackValue=IntegerBox}"

src/Atc.Wpf.Controls/LabelControls/LabelIntegerXyBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<labelControls:LabelContent
1212
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1313
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
14+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1415
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1516
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
1617
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelIntegerXyBox}}, Path=LabelText, FallbackValue=IntegerXyBox}"

src/Atc.Wpf.Controls/LabelControls/LabelPixelSizeBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<labelControls:LabelContent
1212
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1313
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
14+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1415
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1516
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
1617
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelPixelSizeBox}}, Path=LabelText, FallbackValue=PixelSizeBox}"

src/Atc.Wpf.Controls/LabelControls/LabelSlider.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<labelControls:LabelContent
1717
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1818
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
19+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1920
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2021
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2122
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelSlider}}, Path=LabelText, FallbackValue=SliderBox}"

src/Atc.Wpf.Controls/LabelControls/LabelTextBox.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<labelControls:LabelContent
2020
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
2121
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
22+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
2223
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
2324
IsMandatory="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=IsMandatory}"
2425
IsTabStop="False"

src/Atc.Wpf.Controls/LabelControls/LabelTextInfo.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<labelControls:LabelContent
1111
HideAreas="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=HideAreas}"
1212
InformationColor="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationColor}"
13+
InformationContent="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationContent}"
1314
InformationText="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=InformationText}"
1415
LabelText="{Binding RelativeSource={RelativeSource AncestorType={x:Type labelControls:LabelTextInfo}}, Path=LabelText, FallbackValue=TextInfo}"
1516
LabelWidthNumber="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=LabelWidthNumber}"

0 commit comments

Comments
 (0)