In my XAML file, the content page tag looks like this:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:viewmodel="clr-namespace:Tester.ViewModel"
x:DataType="viewmodel:Viewmodel"
x:Class="Tester.View.NewDb"
BackgroundColor="DarkGreen">
<ContentPage.Resources>
<toolkit:InvertedBoolConverter x:Key="InvertedBoolConverter" />
</ContentPage.Resources>
So I have a class called Viewmodel that I'm using for data binding.
I'm trying to bind an entry control to a checkbox control like this:
<Entry Placeholder="Enter Database Password"
Grid.Row="2"
Margin="20,0,20,0"
TextColor="White"
x:Name="dbPasswd"
BindingContext="{x:Reference chkShowPasswd}"
IsPassword="{Binding IsChecked, Converter={StaticResource InvertedBoolConverter}}"/>
<HorizontalStackLayout
Grid.Row="2"
Grid.Column="1"
HorizontalOptions="Center">
<CheckBox x:Name="chkShowPasswd"
VerticalOptions="Center"/>
<Label Text="Show Password"
TextColor="White"
FontSize="Micro"
VerticalOptions="Center"/>
</HorizontalStackLayout>
And when I run the program I get an error message saying:
Binding: Property "IsChecked" not found on Tester.ViewModel.Viewmodel.cs
Now I do have more entry controls in here and I am looking to bind them to ObservableObjects in the Viewmodel code-behind as well as other tasks and methods.
So my question is, how do I bind the two controls I showed in the viewmodel?
Specify the reference to your
CheckBoxin theSourceof your binding: