Skip to content

Commit 937408b

Browse files
committed
Added Semantic binds
1 parent a00a2ea commit 937408b

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

sample/MauiSample/Features/Main/MainPage.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040

4141
<Button
4242
x:Name="CounterBtn"
43-
Text="{Binding ButtonText}"
44-
SemanticProperties.Hint="Counts the number of times you click"
4543
HorizontalOptions="Center"
4644
/>
4745

sample/MauiSample/Features/Main/MainPage.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ protected override void SetupBindings()
1212
{
1313
Binder.WithControl(CounterBtn)
1414
.For(c => c.BindText(), vm => vm.ButtonText)
15-
.Once(c => c.BindClick(), vm => vm.ClickCommand);
15+
.Once(c => c.BindClick(), vm => vm.ClickCommand)
16+
.Once(c => c.BindSemanticHint(), vm => "Counts the number of times you click");
1617

1718
Binder.WithControl(NumberCounter)
19+
.Once(c => c.BindSemanticHeadingLevel(), vm => SemanticHeadingLevel.Level7)
1820
.For(c => c.BindText(), vm => vm.Counter, c => c.ConvertToString());
1921

2022
Binder.WithControl(SecondaryLabel)

src/ShieldMVVM/ExtensionMethods/ControlBindExtensionMethods.Maui.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ public static partial class ControlBindExtensionMethods
2525
/// <returns>Generic BindableProperty of type ItemsView.</returns>
2626
public static Bindings.BindableProperty<IEnumerable<T>> BindItemsSource<T>(this ItemsView _) => Bindings.BindableProperty<IEnumerable<T>>.Create(ItemsView.ItemsSourceProperty);
2727

28+
// ***** SemanticProperties Bindings *****
29+
30+
public static Bindings.BindableProperty<SemanticHeadingLevel> BindSemanticHeadingLevel(this BindableObject _) => Bindings.BindableProperty<SemanticHeadingLevel>.Create(SemanticProperties.HeadingLevelProperty);
31+
public static Bindings.BindableProperty<String> BindSemanticDescription(this BindableObject _) => Bindings.BindableProperty<String>.Create(SemanticProperties.DescriptionProperty);
32+
public static Bindings.BindableProperty<String> BindSemanticHint(this BindableObject _) => Bindings.BindableProperty<String>.Create(SemanticProperties.HintProperty);
33+
34+
2835
// ***** ClickableControl Bindings *****
2936

3037
/// <summary>

0 commit comments

Comments
 (0)