Binding controls to other controls and to classes
This commit is contained in:
15
AdventureWorks.MAUI/Converters/InvertedBoolConverter.cs
Normal file
15
AdventureWorks.MAUI/Converters/InvertedBoolConverter.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
|
||||||
|
namespace AdventureWorks.MAUI.Converters;
|
||||||
|
|
||||||
|
public class InvertedBoolConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return !(bool)value;
|
||||||
|
}
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -30,15 +30,32 @@
|
|||||||
<Entry Grid.Row="3"
|
<Entry Grid.Row="3"
|
||||||
Grid.Column="1" />
|
Grid.Column="1" />
|
||||||
<Label Grid.Row="4"
|
<Label Grid.Row="4"
|
||||||
Text="Cost" />
|
Text="Cost" />
|
||||||
<Entry Grid.Row="4"
|
<HorizontalStackLayout Grid.Row="4"
|
||||||
Grid.Column="1" />
|
Grid.Column="1" >
|
||||||
|
<Entry Text="{Binding Value}"
|
||||||
|
BindingContext="{x:Reference CostStepper}"/>
|
||||||
|
<Stepper x:Name="CostStepper"
|
||||||
|
Minimum="1"
|
||||||
|
Value="10"
|
||||||
|
Maximum="{Binding Value}"
|
||||||
|
BindingContext="{x:Reference PriceStepper}"
|
||||||
|
Increment="1"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
|
||||||
<Label Grid.Row="5"
|
<Label Grid.Row="5"
|
||||||
Text="Price" />
|
Text="Price" />
|
||||||
<Entry Grid.Row="5"
|
<HorizontalStackLayout Grid.Row="5"
|
||||||
Grid.Column="1" />
|
Grid.Column="1" >
|
||||||
|
<Entry Text="{Binding Value}"
|
||||||
|
BindingContext="{x:Reference PriceStepper}"/>
|
||||||
|
<Stepper x:Name="PriceStepper"
|
||||||
|
Value="20"
|
||||||
|
Minimum="{Binding Value}"
|
||||||
|
Maximum="9999"
|
||||||
|
BindingContext="{x:Reference CostStepper}"
|
||||||
|
Increment="1"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
<Label Grid.Row="6"
|
<Label Grid.Row="6"
|
||||||
Text="Size" />
|
Text="Size" />
|
||||||
<Entry Grid.Row="6"
|
<Entry Grid.Row="6"
|
||||||
|
|||||||
@ -3,8 +3,13 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="AdventureWorks.MAUI.Views.UserDetailView"
|
x:Class="AdventureWorks.MAUI.Views.UserDetailView"
|
||||||
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
|
xmlns:partial="clr-namespace:AdventureWorks.MAUI.ViewsPartial"
|
||||||
|
xmlns:converters="clr-namespace:AdventureWorks.MAUI.Converters"
|
||||||
Title="User Information">
|
Title="User Information">
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<converters:InvertedBoolConverter x:Key="invertedBoolean" />
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
<Border Style="{StaticResource Border.Page}">
|
<Border Style="{StaticResource Border.Page}">
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto"
|
<Grid RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto,Auto, Auto, Auto , Auto"
|
||||||
@ -54,7 +59,7 @@
|
|||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
<HorizontalStackLayout >
|
<HorizontalStackLayout >
|
||||||
<Label Text="Flex Time?"/>
|
<Label Text="Flex Time?"/>
|
||||||
<CheckBox IsChecked="False"/>
|
<CheckBox x:Name="FlexTime"/>
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
<HorizontalStackLayout >
|
<HorizontalStackLayout >
|
||||||
<Label Text="Health Care?"/>
|
<Label Text="Health Care?"/>
|
||||||
@ -78,7 +83,8 @@
|
|||||||
Direction="Row">
|
Direction="Row">
|
||||||
<HorizontalStackLayout>
|
<HorizontalStackLayout>
|
||||||
<Label Text="Full-Time"/>
|
<Label Text="Full-Time"/>
|
||||||
<RadioButton IsChecked="True"
|
<RadioButton x:Name="FullTime"
|
||||||
|
IsChecked="True"
|
||||||
GroupName="EmployeeType"/>
|
GroupName="EmployeeType"/>
|
||||||
</HorizontalStackLayout>
|
</HorizontalStackLayout>
|
||||||
<HorizontalStackLayout>
|
<HorizontalStackLayout>
|
||||||
@ -96,7 +102,9 @@
|
|||||||
Grid.Row="9"/>
|
Grid.Row="9"/>
|
||||||
<TimePicker Grid.Row="9"
|
<TimePicker Grid.Row="9"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Time="06:00:00"/>
|
Time="06:00:00"
|
||||||
|
BindingContext="{x:Reference FullTime}"
|
||||||
|
IsEnabled="{Binding IsChecked, Converter={StaticResource invertedBoolean}}"/>
|
||||||
|
|
||||||
<Label Text="Phone"
|
<Label Text="Phone"
|
||||||
Grid.Row="10"/>
|
Grid.Row="10"/>
|
||||||
@ -106,6 +114,8 @@
|
|||||||
Direction="Row">
|
Direction="Row">
|
||||||
<HorizontalStackLayout>
|
<HorizontalStackLayout>
|
||||||
<Entry MinimumWidthRequest="120"/>
|
<Entry MinimumWidthRequest="120"/>
|
||||||
|
</HorizontalStackLayout>
|
||||||
|
<HorizontalStackLayout>
|
||||||
<Picker>
|
<Picker>
|
||||||
<Picker.ItemsSource>
|
<Picker.ItemsSource>
|
||||||
<x:Array Type="{x:Type x:String}">
|
<x:Array Type="{x:Type x:String}">
|
||||||
|
|||||||
Reference in New Issue
Block a user