Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 4.50 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <ContentView xmlns="http://xamarin.com/schemas/2014/forms"
  4.    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
  5.    xmlns:behaviors="clr-namespace:AlloyMobileComponents.Behaviors"
  6.    xmlns:constants="clr-namespace:AlloyMobileComponents.Constants;assembly=AlloyMobileComponents"
  7.    xmlns:inputBehaviors="clr-namespace:AlloyMobileComponents.Views.Inputs.Behaviors"
  8.    xmlns:inputs="clr-namespace:AlloyMobileComponents.Views.Inputs;assembly=AlloyMobileComponents"
  9.    xmlns:customControls="clr-namespace:AlloyMobileComponents.CustomControls;assembly=AlloyMobileComponents"
  10.    xmlns:converters="clr-namespace:AlloyMobileComponents.Converters;assembly=AlloyMobileComponents"
  11.    x:Class="AlloyMobileComponents.Views.Inputs.InputNumber"
  12.    x:DataType="inputs:InputNumberViewModel"
  13.    HeightRequest="50"
  14.    HorizontalOptions="FillAndExpand">
  15.   <ContentView.Resources>
  16.     <ResourceDictionary>
  17.       <!-- converter for input number values -->
  18.       <converters:NullableDoubleToStringConverter x:Key="NullableDoubleToStringConverter" />
  19.       <converters:NullableDoubleToStringConverterParameters x:Key="NullableDoubleToStringConverterParameters" />
  20.       <!-- styles for entry control -->
  21.       <Style x:Key="EntryStyle"
  22.          TargetType="customControls:CustomEntry">
  23.         <Setter Property="FontFamily"
  24.            Value="{x:Static constants:FontConstants.FontFamilyNormal}" />
  25.         <Setter Property="FontSize"
  26.            Value="{x:Static constants:FontConstants.FontSizeDefault}" />
  27.         <Setter Property="HeightRequest"
  28.            Value="50" />
  29.         <Setter Property="TextColor"
  30.            Value="{x:Static constants:ColourConstants.DarkBlue}" />
  31.         <Setter Property="VerticalTextAlignment"
  32.            Value="Center" />
  33.       </Style>
  34.       <!-- styles for label control -->
  35.       <Style x:Key="LabelStyle"
  36.          TargetType="Label">
  37.         <!-- required anchor for animating the labels out the way -->
  38.         <Setter Property="AnchorX"
  39.            Value="0" />
  40.         <Setter Property="AnchorY"
  41.            Value="0" />
  42.         <Setter Property="FontFamily"
  43.            Value="{x:Static constants:FontConstants.FontFamilyBold}" />
  44.         <Setter Property="FontSize"
  45.            Value="{x:Static constants:FontConstants.FontSizeDefault}" />
  46.         <Setter Property="HeightRequest"
  47.            Value="50" />
  48.         <!-- turns off events being capture for the label -->
  49.         <Setter Property="InputTransparent"
  50.            Value="True" />
  51.         <Setter Property="TextColor"
  52.            Value="{x:Static constants:ColourConstants.LightBlue}" />
  53.         <Setter Property="VerticalTextAlignment"
  54.            Value="Center" />
  55.       </Style>
  56.     </ResourceDictionary>
  57.   </ContentView.Resources>
  58.   <ContentView.Content>
  59.     <RelativeLayout>
  60.       <!-- the text entry control -->
  61.       <customControls:CustomEntry AutomationId="{x:Static inputs:InputString.ValueAutomationId}"
  62.          Keyboard="Numeric"
  63.          Style="{x:StaticResource EntryStyle}"
  64.          Text="{Binding Value, Converter={x:StaticResource NullableDoubleToStringConverter}, ConverterParameter={x:StaticResource NullableDoubleToStringConverterParameters}}"
  65.          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=0}"
  66.          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=0}"
  67.          x:Name="EntryValue">
  68.         <customControls:CustomEntry.Behaviors>
  69.           <!-- only allow numeric input -->
  70.           <behaviors:NumbersOnlyBehavior />
  71.           <!-- animate labels -->
  72.           <inputBehaviors:InputLabelAnimationBehavior Label="{x:Reference LabelTitle}" />
  73.         </customControls:CustomEntry.Behaviors>
  74.       </customControls:CustomEntry>
  75.       <!-- the label/placeholder than animates in and out -->
  76.       <Label AutomationId="{x:Static inputs:InputString.TitleAutomationId}"
  77.          Style="{x:StaticResource LabelStyle}"
  78.          Text="{Binding Title}"
  79.          RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=10}"
  80.          RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0, Constant=0}"
  81.          RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=1, Constant=-20}"
  82.          x:Name="LabelTitle" />
  83.     </RelativeLayout>
  84.   </ContentView.Content>
  85. </ContentView>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement