TextBoxEditor.xaml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:wpf="clr-namespace:FWindSoft.Wpf"
  5. xmlns:local="clr-namespace:FWindSoft.Wpf.Controls">
  6. <Style TargetType="{x:Type local:TextBoxEditor}">
  7. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  8. <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
  9. <Setter Property="BorderBrush" Value="Black"/>
  10. <Setter Property="BorderThickness" Value="1"/>
  11. <Setter Property="Padding" Value="1"/>
  12. <Setter Property="AllowDrop" Value="true"/>
  13. <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
  14. <Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
  15. <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
  16. <Setter Property="Template">
  17. <Setter.Value>
  18. <ControlTemplate TargetType="{x:Type local:TextBoxEditor}">
  19. <ControlTemplate.Resources>
  20. <Style TargetType="{x:Type Button}">
  21. <!--<Setter Property="BorderThickness" Value="1"></Setter>-->
  22. <!--<Setter Property="BorderBrush" Value="Black"></Setter>-->
  23. <Setter Property="Background" Value="White"></Setter>
  24. <Setter Property="Opacity" Value="1"></Setter>
  25. <Setter Property="Padding" Value="5,0,5,0"></Setter>
  26. <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
  27. <Setter Property="Template">
  28. <Setter.Value>
  29. <ControlTemplate>
  30. <Border Name="Border" BorderThickness="{TemplateBinding Button.BorderThickness}" BorderBrush="{TemplateBinding Button.BorderBrush}" Background="{TemplateBinding Button.Background}" >
  31. <Grid Margin="{TemplateBinding Padding}" HorizontalAlignment="Stretch">
  32. <Grid.ColumnDefinitions>
  33. <ColumnDefinition Width="Auto"></ColumnDefinition>
  34. <ColumnDefinition></ColumnDefinition>
  35. </Grid.ColumnDefinitions>
  36. <ContentPresenter Grid.Column="1" Content="{TemplateBinding ContentControl.Content}" VerticalAlignment="Center" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"></ContentPresenter>
  37. </Grid>
  38. </Border>
  39. <ControlTemplate.Triggers>
  40. <Trigger Property="IsMouseOver" Value="true">
  41. <Setter Property="Background" Value="#FFCBC6C6"/>
  42. <Setter Property="BorderThickness" Value="1"></Setter>
  43. <Trigger.EnterActions>
  44. <BeginStoryboard>
  45. <Storyboard TargetName="Border">
  46. <DoubleAnimation Storyboard.TargetProperty="Opacity" To="0.5" Duration="0:0:1" />
  47. </Storyboard>
  48. </BeginStoryboard>
  49. </Trigger.EnterActions>
  50. <Trigger.ExitActions>
  51. <BeginStoryboard>
  52. <Storyboard TargetName="Border">
  53. <DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:1" />
  54. </Storyboard>
  55. </BeginStoryboard>
  56. </Trigger.ExitActions>
  57. </Trigger>
  58. <Trigger Property="IsEnabled" Value="False">
  59. <Setter Property="Button.Foreground" TargetName="Border" Value="Gray" />
  60. </Trigger>
  61. </ControlTemplate.Triggers>
  62. </ControlTemplate>
  63. </Setter.Value>
  64. </Setter>
  65. </Style>
  66. </ControlTemplate.Resources>
  67. <Border Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
  68. <Grid >
  69. <Grid x:Name="Show" HorizontalAlignment="Stretch" Visibility="Visible">
  70. <Grid.ColumnDefinitions>
  71. <ColumnDefinition></ColumnDefinition>
  72. <ColumnDefinition Width="Auto"></ColumnDefinition>
  73. </Grid.ColumnDefinitions>
  74. <TextBlock Name="PART_TextShow" VerticalAlignment="Center" Text="{TemplateBinding Property=Text}" ></TextBlock>
  75. <StackPanel Name="Stack" Grid.Column="1" Orientation="Horizontal" >
  76. <Button Name="BtnUpdate" Content="{wpf:FontIcon Icon=Pencil}" BorderThickness="0" FontFamily="{DynamicResource ResourceKey={x:Static wpf:FontsUtil.AwesomeKey}}" Width="30" FontSize="20" ></Button>
  77. </StackPanel>
  78. </Grid>
  79. <Grid x:Name="Editing" HorizontalAlignment="Stretch" Visibility="Collapsed">
  80. <Grid.ColumnDefinitions>
  81. <ColumnDefinition></ColumnDefinition>
  82. <ColumnDefinition Width="Auto"></ColumnDefinition>
  83. </Grid.ColumnDefinitions>
  84. <TextBox x:Name="PART_ContentHost" VerticalAlignment="Stretch" VerticalContentAlignment="Center" Text="{Binding Text,RelativeSource={RelativeSource TemplatedParent}}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
  85. <StackPanel Name="StackEdit" Grid.Column="1" Orientation="Horizontal">
  86. <Button Name="BtnClear" Content="{wpf:FontIcon Icon=Times}" BorderThickness="0" FontFamily="{DynamicResource ResourceKey={x:Static wpf:FontsUtil.AwesomeKey}}" Width="30" FontSize="20" ></Button>
  87. <Button Name="BtnComplete" Content="{wpf:FontIcon Icon=Check}" BorderThickness="0" FontFamily="{DynamicResource ResourceKey={x:Static wpf:FontsUtil.AwesomeKey}}" Width="30" FontSize="20" Command="{TemplateBinding Command}" CommandParameter="{TemplateBinding CommandParameter}"></Button>
  88. </StackPanel>
  89. </Grid>
  90. </Grid>
  91. </Border>
  92. <ControlTemplate.Triggers>
  93. <Trigger Property="IsEditing" Value="True">
  94. <Setter Property="Visibility" TargetName="Show" Value="Collapsed"/>
  95. <Setter Property="Visibility" TargetName="Editing" Value="Visible" />
  96. </Trigger>
  97. <Trigger Property="IsEnabled" Value="false">
  98. <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
  99. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  100. </Trigger>
  101. </ControlTemplate.Triggers>
  102. </ControlTemplate>
  103. </Setter.Value>
  104. </Setter>
  105. <!--<Style.Triggers>
  106. <MultiTrigger>
  107. <MultiTrigger.Conditions>
  108. <Condition Property="IsInactiveSelectionHighlightEnabled" SourceName="PART_ContentHost" Value="true"/>
  109. <Condition Property="IsSelectionActive" Value="false"/>
  110. </MultiTrigger.Conditions>
  111. <Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
  112. </MultiTrigger>
  113. </Style.Triggers>-->
  114. </Style>
  115. </ResourceDictionary>