PMCounterValueTextBox.xaml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <UserControl x:Class="MECF.Framework.UI.Core.Control.PMCounterValueTextBox"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:local="clr-namespace:MECF.Framework.UI.Core.Control"
  7. xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters"
  8. mc:Ignorable="d" x:Name="self"
  9. d:DesignHeight="35" d:DesignWidth="200">
  10. <UserControl.Resources>
  11. <converters:NumberStringToBool x:Key="numberStringToBool"/>
  12. <converters:StringToVisibility x:Key="stringToVisibility"/>
  13. <Style TargetType="TextBox" x:Key="CustomStyle">
  14. <Style.Triggers>
  15. <DataTrigger Binding="{Binding ElementName=self,Path=Value}" Value="Value">
  16. <Setter Property="Background" Value="#FFDAE5F1"/>
  17. <Setter Property="BorderThickness" Value="0"/>
  18. </DataTrigger>
  19. </Style.Triggers>
  20. </Style>
  21. </UserControl.Resources>
  22. <TextBox Name="txtInput" VerticalContentAlignment="Center"
  23. Text="{Binding ElementName=self,Path=Value,Mode=TwoWay}"
  24. IsReadOnly="{Binding ElementName=self,Path=Value,Converter={StaticResource numberStringToBool}}"
  25. PreviewTextInput="OnPreviewTextInput"
  26. InputMethod.IsInputMethodEnabled="False"
  27. KeyDown="TextBox_KeyDown"
  28. Width="200" HorizontalAlignment="Center" HorizontalContentAlignment="Center" VerticalAlignment="Center"
  29. Visibility="{Binding ElementName=self,Path=Value,Converter={StaticResource stringToVisibility}}"
  30. LostFocus="TextBox_LostFocus"
  31. Style="{StaticResource CustomStyle}"/>
  32. </UserControl>