見下圖,如何將下拉列表邊框與實際的組合框對齊?https://imgur.com/uNO45F2這是 Combobox 的代碼,它使用自定義的 ComboBoxItem 樣式,<ComboBox Grid.Row="0" Grid.Column="0" ItemsSource="{Binding ASDevicesView, Mode=OneWay , UpdateSourceTrigger=PropertyChanged}" AutomationProperties.AutomationId="4314" SelectedItem="{Binding SDevice}" IsEditable="True" Text="{Binding SearchText}" MaxDropDownHeight="166" ItemContainerStyle="{StaticResource MyComboBoxItemStyle}"> <ComboBox.Style> <Style TargetType="{x:Type ComboBox}"> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value="True"> <Setter Property="IsDropDownOpen" Value="true" /> </Trigger> </Style.Triggers> </Style> </ComboBox.Style></ComboBox>這是 ComboBoxItem 樣式的代碼,<Style x:Key="MyComboBoxItemStyle" BasedOn="{StaticResource {x:Type ComboBoxItem}}" TargetType="{x:Type ComboBoxItem}"> <Setter Property="HorizontalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" /> <Setter Property="Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualWidth}" /> <Setter Property="Height" Value="40" />
- 1 回答
- 0 關注
- 92 瀏覽
添加回答
舉報
0/150
提交
取消