网站制作寻找客户,asp一个空间建多个网站系统,深圳外贸网站推广公司,如何修改网站模板内容WPF开发者QQ群#xff1a; 340500857 有小伙伴需要实现ComboBox下拉框带水印#xff0c;并且选择Item内容后水印默认从中间到顶部。Item需要展示图文#xff0c;选择后的数据展示图文。欢迎转发、分享、点赞#xff0c;谢谢大家~。效果如下#xff1a;一、Xaml代码如下 340500857 有小伙伴需要实现ComboBox下拉框带水印并且选择Item内容后水印默认从中间到顶部。Item需要展示图文选择后的数据展示图文。欢迎转发、分享、点赞谢谢大家~。效果如下一、Xaml代码如下 Window.ResourcesStyle TargetTypeToggleButton x:KeyComboxStyleBtnSetter PropertyTemplateSetter.ValueControlTemplateBorder x:NameBack BackgroundTransparentPath NamePathFill FillBlack Width10 Height6 StrokeThickness0 DataM5,0 L10,10 L0,10 z RenderTransformOrigin0.5,0.5 StretchFillPath.RenderTransformTransformGroupScaleTransform/SkewTransform/RotateTransform Angle180/TranslateTransform//TransformGroup/Path.RenderTransform/Path/BorderControlTemplate.TriggersTrigger PropertyIsMouseOver ValueTrueSetter TargetNamePathFill PropertyFill Valuegray/Setter/Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter
/StyleStyle TargetTypeComboBox x:KeyComboBoxStyleSetter PropertyItemContainerStyleSetter.ValueStyle TargetTypeComboBoxItemSetter PropertyMinHeight Value22/SetterSetter PropertyMinWidth Value60/SetterSetter PropertyForeground ValueBlack/Setter PropertyTemplateSetter.ValueControlTemplate TargetTypeComboBoxItemBorder NameBack BackgroundWhite BorderThickness0,0,0,0 BorderBrush#81D779 ContentPresenter ContentSource{Binding Source} VerticalAlignmentCenter HorizontalAlignmentLeft/ContentPresenter/BorderControlTemplate.TriggersTrigger PropertyIsHighlighted ValueTrueSetter TargetNameBack PropertyBackground ValuePink/Setter/TriggerTrigger PropertyIsSelected ValueTrueSetter PropertyBackground ValueRed //TriggerTrigger PropertyIsMouseOver ValueTrueSetter PropertyBackground ValueAliceBlue //Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter
/Style/Setter.Value/SetterSetter PropertyTemplateSetter.ValueControlTemplate TargetTypeComboBoxGridGrid.ColumnDefinitionsColumnDefinition Width0.7*/ColumnDefinition Width0.3* MaxWidth30//Grid.ColumnDefinitionsTextBlock x:Name_watermark Text已选择emoji Margin60,6,0,0 ForegroundGray Grid.Column0 VerticalAlignmentTop/TextBlockContentPresenter Grid.Column0ContentTemplate{TemplateBinding SelectionBoxItemTemplate} Content{TemplateBinding SelectionBoxItem}VerticalAlignmentCenter Margin2,10,0,0/ContentPresenterBorder Grid.ColumnSpan2 BorderBrush#abadb3 BorderThickness1/ToggleButton Grid.Column1 Style{StaticResource ComboxStyleBtn} IsChecked{Binding PathIsDropDownOpen, ModeTwoWay, RelativeSource{RelativeSource TemplatedParent}} ClickModePress/ToggleButtonPopup IsOpen{TemplateBinding IsDropDownOpen} PlacementBottom x:NamePopup FocusableFalse AllowsTransparencyTrue PopupAnimationSlide Border CornerRadius1 BorderBrush#5A5A5A BorderThickness1,0,1,1 BackgroundWhite MaxHeight{TemplateBinding MaxDropDownHeight} MinWidth{TemplateBinding ActualWidth} x:NameDropDown SnapsToDevicePixelsTrueBorder.EffectDropShadowEffect ColorGray BlurRadius2 ShadowDepth0 Opacity1//Border.EffectScrollViewer Margin0,0,0,0 SnapsToDevicePixelsTrue HorizontalScrollBarVisibilityAuto VerticalScrollBarVisibilityAutoVirtualizingStackPanel IsItemsHostTrue KeyboardNavigation.DirectionalNavigationContained //ScrollViewer/Border/Popup/GridControlTemplate.TriggersTrigger PropertyText Value{x:Null}Setter TargetName_watermark PropertyVerticalAlignment ValueCenter/Setter TargetName_watermark PropertyMargin Value10,0,0,0/Setter TargetName_watermark PropertyText Value请选择emoji//TriggerTrigger PropertyText ValueSetter TargetName_watermark PropertyVerticalAlignment ValueCenter/Setter TargetName_watermark PropertyMargin Value10,0,0,0/Setter TargetName_watermark PropertyText Value请选择emoji//Trigger/ControlTemplate.Triggers/ControlTemplate/Setter.Value/Setter/StyleDataTemplate x:KeycomboBoxItemDataTemplateWrapPanelImage Source{Binding ImagesPath} Width60 Height60/TextBlock Text{Binding Text} VerticalAlignmentCenter Padding4,0//WrapPanel/DataTemplate/Window.ResourcesGridComboBox NamecomboBoxArrayWidth200Height100Style{StaticResource ComboBoxStyle} ItemTemplate{StaticResource comboBoxItemDataTemplate}/ComboBox/Grid
二、Xaml.cs代码如下public partial class MainWindow : Window{public MainWindow(){InitializeComponent();var array new ListItemModel();for (int i 0; i 11; i){array.Add(new ItemModel { ImagesPath new BitmapImage(new Uri(string.Format(pack://application:,,,/WpfComboBox;component/Images/{0}.png, i.ToString()))), Text Item i.ToString() });}this.comboBoxArray.ItemsSource array;}}public class ItemModel{public ImageSource ImagesPath { get; set; }public string Text { get; set; }}
源码地址QQ群-“文件”-“开源项目”- 【水印图文】WpfComboBox.rar“WPF开发者QQ群 340500857 blogs https://www.cnblogs.com/yanjinhuaGithubhttps://github.com/yanjinhuagood出处https://www.cnblogs.com/yanjinhua版权本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。转载请著名作者 出处 https://github.com/yanjinhuagood