123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?xml version="1.0" encoding="utf-8"?>
- <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:material="clr-namespace:XF.Material.Forms.UI;assembly=XF.Material"
- xmlns:local="clr-namespace:InABox.Mobile"
- x:Class="InABox.Mobile.MobileButton">
- <ContentView.Resources>
-
- <local:StringToBooleanConverter x:Key="StringToBooleanConverter"/>
- <local:ImageSourceToBooleanConverter x:Key="ImageSourceToBooleanConverter"/>
- <local:MobileButtonTextFormatter x:Key="MobileButtonTextFormatter" x:Name="_textformatter"/>
- </ContentView.Resources>
- <ContentView.ControlTemplate>
- <ControlTemplate>
- <material:MaterialCard
- x:Name="_frame"
- CornerRadius = "5"
- Elevation = "0"
- Margin = "0"
- HasShadow = "False"
- Padding="0"
- IsClickable = "True"
- IsEnabled="True"
- BackgroundColor="{TemplateBinding BackgroundColor}"
- BorderColor="{TemplateBinding BorderColor}"
- Clicked="_frame_OnClicked">
- <material:MaterialCard.Triggers>
- <!-- <DataTrigger TargetType="material:MaterialCard" Binding="{TemplateBinding IsEnabled}" Value="True"> -->
- <!-- <Setter Property="BackgroundColor" Value="{TemplateBinding ButtonColor}" /> -->
- <!-- </DataTrigger> -->
- <DataTrigger TargetType="material:MaterialCard" Binding="{TemplateBinding IsEnabled}" Value="False">
- <Setter Property="BackgroundColor" Value="Silver" />
- </DataTrigger>
- <!-- <DataTrigger TargetType="material:MaterialCard" Binding="{TemplateBinding IsEnabled}" Value="True"> -->
- <!-- <Setter Property="BorderColor" Value="{TemplateBinding BorderColor}" /> -->
- <!-- </DataTrigger> -->
- <DataTrigger TargetType="material:MaterialCard" Binding="{TemplateBinding IsEnabled}" Value="False">
- <Setter Property="BorderColor" Value="Gray" />
- </DataTrigger>
- </material:MaterialCard.Triggers>
- <Grid>
- <Grid
- Grid.Row="0"
- Grid.Column="0"
- Padding = "{TemplateBinding Padding}">
-
- <StackLayout
- x:Name="_layout"
- Grid.Row="0"
- Grid.Column="0"
- Orientation="{TemplateBinding Orientation}"
- HorizontalOptions = "CenterAndExpand"
- VerticalOptions = "CenterAndExpand">
-
- <Image
- x:Name="_image"
- Source="{TemplateBinding Image}"
- IsVisible="{TemplateBinding Image, Converter={StaticResource ImageSourceToBooleanConverter}}"
- WidthRequest="24"
- HeightRequest="24"
- Aspect="AspectFit"
- />
-
- <material:MaterialLabel
- x:Name="_label"
- Text="{TemplateBinding Text, Converter={StaticResource MobileButtonTextFormatter}}"
- VerticalOptions="CenterAndExpand"
- HorizontalOptions="FillAndExpand"
- TypeScale = "{TemplateBinding TypeScale}"
- HorizontalTextAlignment = "Center"
- TextColor="{TemplateBinding TextColor}"
- IsVisible="{TemplateBinding Text, Converter={StaticResource StringToBooleanConverter}}"
- >
- <material:MaterialLabel.Triggers>
- <DataTrigger TargetType="material:MaterialLabel" Binding="{TemplateBinding IsEnabled}" Value="False">
- <Setter Property="TextColor" Value="Gray" />
- </DataTrigger>
- </material:MaterialLabel.Triggers>
- </material:MaterialLabel>
-
- </StackLayout>
-
- </Grid>
-
- <Frame
- Grid.Row="0"
- Grid.Column="0"
- HorizontalOptions="End"
- VerticalOptions="Start"
- HeightRequest="20"
- WidthRequest="20"
- CornerRadius="15"
- IsVisible="{TemplateBinding Alert, Converter={StaticResource StringToBooleanConverter}}"
- HasShadow="False"
- Margin="0,2,2,0"
- BackgroundColor="Yellow" Padding="1">
- <Label
- FontAttributes="Bold"
- TextColor="Red"
- FontSize="Micro"
- HorizontalOptions="Center"
- VerticalOptions="Center"
- Text="{TemplateBinding Alert}"/>
- </Frame>
-
- </Grid>
-
- </material:MaterialCard>
- </ControlTemplate>
- </ContentView.ControlTemplate>
- </ContentView>
|