Skip to content

Commit cd0e17e

Browse files
committed
fix a bug (AutoCompleteComboBox.Watermark visible)
1 parent 20cb77f commit cd0e17e

File tree

1 file changed

+37
-28
lines changed
  • AutoCompleteTextBox/AutoCompleteTextBox/Editors/Themes

1 file changed

+37
-28
lines changed

AutoCompleteTextBox/AutoCompleteTextBox/Editors/Themes/Generic.xaml

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
<BooleanToVisibilityConverter x:Key="BoolToVisConverter" />
77

8-
<Style x:Key="TextBoxSuggestionItemStyle" TargetType="ListBoxItem">
8+
<Style x:Key="TextBoxSuggestionItemStyle" TargetType="{x:Type ListBoxItem}">
99
<Setter Property="Template">
1010
<Setter.Value>
11-
<ControlTemplate TargetType="ListBoxItem">
11+
<ControlTemplate TargetType="{x:Type ListBoxItem}">
1212
<Border x:Name="ContentBorder" Background="{Binding Path=SuggestionBackground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=editors:AutoCompleteTextBox}, Mode=OneWay}">
1313
<ContentPresenter />
1414
</Border>
@@ -26,10 +26,10 @@
2626
</Setter>
2727
</Style>
2828

29-
<Style x:Key="ComboBoxSuggestionItemStyle" TargetType="ListBoxItem">
29+
<Style x:Key="ComboBoxSuggestionItemStyle" TargetType="{x:Type ListBoxItem}">
3030
<Setter Property="Template">
3131
<Setter.Value>
32-
<ControlTemplate TargetType="ListBoxItem">
32+
<ControlTemplate TargetType="{x:Type ListBoxItem}">
3333
<Border x:Name="ContentBorder" Background="{Binding Path=SuggestionBackground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=editors:AutoCompleteComboBox}, Mode=OneWay}">
3434
<ContentPresenter />
3535
</Border>
@@ -167,10 +167,11 @@
167167
</Setter>
168168
</Style>
169169

170-
<Style TargetType="editors:AutoCompleteComboBox">
170+
<Style TargetType="{x:Type editors:AutoCompleteComboBox}">
171171
<Setter Property="Focusable" Value="True" />
172172
<Setter Property="SuggestionBackground" Value="White" />
173-
<Setter Property="BorderThickness" Value="0,0,0,1" />
173+
<Setter Property="BorderThickness" Value="1" />
174+
<Setter Property="BorderBrush" Value="#FFABADB3" />
174175
<Setter Property="Background" Value="Transparent" />
175176
<Setter Property="HorizontalContentAlignment" Value="Left" />
176177
<Setter Property="VerticalContentAlignment" Value="Top" />
@@ -182,33 +183,42 @@
182183
<Setter.Value>
183184
<ControlTemplate TargetType="{x:Type editors:AutoCompleteComboBox}">
184185
<Grid>
185-
<DockPanel>
186-
<ContentPresenter
187-
x:Name="PART_Icon"
188-
ContentSource="Icon"
189-
Visibility="{TemplateBinding IconVisibility}" />
190-
<Grid>
191-
<TextBlock
192-
x:Name="PART_Watermark"
193-
HorizontalAlignment="Left"
194-
VerticalAlignment="Center"
195-
DockPanel.Dock="Left"
196-
Focusable="False"
197-
Foreground="Gray"
198-
Text="{TemplateBinding Watermark}"
199-
Visibility="Collapsed" />
200-
<DockPanel Margin="3,0">
201-
<Expander x:Name="PART_Expander" DockPanel.Dock="Right" />
186+
<ContentPresenter
187+
x:Name="PART_Icon"
188+
ContentSource="Icon"
189+
Visibility="{TemplateBinding IconVisibility}" />
190+
<Grid Margin="3,0">
191+
<Grid.ColumnDefinitions>
192+
<ColumnDefinition Width="*" />
193+
<ColumnDefinition Width="Auto" />
194+
</Grid.ColumnDefinitions>
195+
<Border
196+
Background="{TemplateBinding Background}"
197+
BorderBrush="{TemplateBinding BorderBrush}"
198+
BorderThickness="{TemplateBinding BorderThickness}"
199+
CornerRadius="0">
200+
<Grid>
201+
<TextBlock
202+
x:Name="PART_Watermark"
203+
Margin="3,0"
204+
HorizontalAlignment="Left"
205+
VerticalAlignment="Center"
206+
Focusable="False"
207+
Foreground="Gray"
208+
Text="{TemplateBinding Watermark}"
209+
Visibility="Collapsed" />
202210
<TextBox
203211
x:Name="PART_Editor"
204212
HorizontalAlignment="Stretch"
205213
VerticalAlignment="Center"
206214
CharacterCasing="{Binding Path=CharacterCasing, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
207215
Focusable="True"
208-
MaxLength="{Binding Path=MaxLength, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}" />
209-
</DockPanel>
210-
</Grid>
211-
</DockPanel>
216+
MaxLength="{Binding Path=MaxLength, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay}"
217+
Style="{StaticResource ResourceKey=TransparentTextBoxStyle}" />
218+
</Grid>
219+
</Border>
220+
<Expander x:Name="PART_Expander" Grid.Column="1" />
221+
</Grid>
212222
<Popup
213223
x:Name="PART_Popup"
214224
MinWidth="{TemplateBinding ActualWidth}"
@@ -246,7 +256,6 @@
246256
</Popup>
247257

248258
</Grid>
249-
<!--</Border>-->
250259
<ControlTemplate.Triggers>
251260
<Trigger SourceName="PART_Editor" Property="Text" Value="">
252261
<Setter TargetName="PART_Watermark" Property="Visibility" Value="Visible" />

0 commit comments

Comments
 (0)