Skip to content

Commit

Permalink
Add xmlns:control and x:DataType to various XAML files
Browse files Browse the repository at this point in the history
Added xmlns:control namespace to reference App.Controls or
App.Controls.CustomSwitchExamples in multiple XAML files.
Added x:DataType attribute to enable compile-time data binding
checks and IntelliSense support. Reordered xmlns:stateButton
namespace and added x:DataType in CustomButton.xaml. Added
x:DataType to examples:IosSwitch elements and DataTrigger
elements in IsBusyTestPage.xaml and IsEnabledTestPage.xaml.
Added x:DataType to Grid element in CustomSwitch.xaml.
  • Loading branch information
IeuanWalker committed Nov 19, 2024
1 parent 383b150 commit 22caa4c
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 17 deletions.
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomButton.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomButton"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:stateButton="clr-namespace:IeuanWalker.Maui.StateButton;assembly=IeuanWalker.Maui.StateButton">
xmlns:control="clr-namespace:App.Controls"
xmlns:stateButton="clr-namespace:IeuanWalker.Maui.StateButton;assembly=IeuanWalker.Maui.StateButton"
x:DataType="control:CustomButton">
<ContentView.ControlTemplate>
<ControlTemplate>
<stateButton:StateButton Padding="20,20"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/AndroidSwitch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.AndroidSwitch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:AndroidSwitch">
<switch:CustomSwitch BackgroundColor="#A6A6A6"
HeightRequest="20"
HorizontalOptions="Center"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/IosSwitch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.IosSwitch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:IosSwitch">
<switch:CustomSwitch HeightRequest="40"
HorizontalKnobMargin="1"
IsBusy="{Binding IsBusy, Source={RelativeSource AncestorType={x:Type ContentView}}}"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Other1Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Other1Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Other1Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="40"
IsToggled="{Binding IsToggled, Source={RelativeSource AncestorType={x:Type ContentView}}}"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Other2Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Other2Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Other2Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="40"
HorizontalKnobMargin="3"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Other3Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Other3Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Other3Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="35"
HorizontalKnobMargin="-1"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Other4Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Other4Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Other4Switch">
<switch:CustomSwitch BackgroundColor="#f3f3f2"
HeightRequest="50"
IsToggled="{Binding IsToggled, Source={RelativeSource AncestorType={x:Type ContentView}}}"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Other5Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Other5Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Other5Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="50"
IsToggled="{Binding IsToggled, Source={RelativeSource AncestorType={x:Type ContentView}}}"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Theme1Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Theme1Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Theme1Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="50"
IsToggled="{Binding IsToggled, Source={RelativeSource AncestorType={x:Type ContentView}}}"
Expand Down
4 changes: 3 additions & 1 deletion Demo/App/Controls/CustomSwitchExamples/Theme2Switch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<ContentView x:Class="App.Controls.CustomSwitchExamples.Theme2Switch"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch">
xmlns:control="clr-namespace:App.Controls.CustomSwitchExamples"
xmlns:switch="clr-namespace:IeuanWalker.Maui.Switch;assembly=IeuanWalker.Maui.Switch"
x:DataType="control:Theme2Switch">
<switch:CustomSwitch BackgroundColor="White"
HeightRequest="40"
HorizontalKnobMargin="2"
Expand Down
14 changes: 10 additions & 4 deletions Demo/App/Pages/IsBusyTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,24 @@
<examples:AndroidSwitch x:Name="DynamicToggle" />
</HorizontalStackLayout>

<examples:IosSwitch IsBusy="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}" IsToggled="False">
<examples:IosSwitch x:DataType="examples:AndroidSwitch"
IsBusy="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
IsToggled="False">
<examples:IosSwitch.Triggers>
<DataTrigger Binding="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
<DataTrigger x:DataType="examples:AndroidSwitch"
Binding="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
TargetType="examples:IosSwitch"
Value="True">
<Setter Property="IsEnabled" Value="False" />
</DataTrigger>
</examples:IosSwitch.Triggers>
</examples:IosSwitch>
<examples:IosSwitch IsBusy="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}" IsToggled="True">
<examples:IosSwitch x:DataType="examples:AndroidSwitch"
IsBusy="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
IsToggled="True">
<examples:IosSwitch.Triggers>
<DataTrigger Binding="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
<DataTrigger x:DataType="examples:AndroidSwitch"
Binding="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
TargetType="examples:IosSwitch"
Value="True">
<Setter Property="IsEnabled" Value="False" />
Expand Down
8 changes: 6 additions & 2 deletions Demo/App/Pages/IsEnabledTestPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@
<examples:AndroidSwitch x:Name="DynamicToggle" />
</HorizontalStackLayout>

<examples:IosSwitch IsEnabled="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}" IsToggled="False" />
<examples:IosSwitch IsEnabled="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}" IsToggled="True" />
<examples:IosSwitch x:DataType="examples:AndroidSwitch"
IsEnabled="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
IsToggled="False" />
<examples:IosSwitch x:DataType="examples:AndroidSwitch"
IsEnabled="{Binding Source={x:Reference DynamicToggle}, Path=IsToggled}"
IsToggled="True" />

</VerticalStackLayout>
</ScrollView>
Expand Down
4 changes: 3 additions & 1 deletion Scr/Switch/CustomSwitch.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:view="clr-namespace:IeuanWalker.Maui.Switch">
<view:SwitchView.Content>
<Grid AutomationProperties.ExcludedWithChildren="True" AutomationProperties.IsInAccessibleTree="False">
<Grid x:DataType="view:CustomSwitch"
AutomationProperties.ExcludedWithChildren="True"
AutomationProperties.IsInAccessibleTree="False">
<Grid.GestureRecognizers>
<TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped" />
<PanGestureRecognizer PanUpdated="PanGestureRecognizer_PanUpdated" />
Expand Down

0 comments on commit 22caa4c

Please sign in to comment.