当前位置: 首页 > news >正文

网站建设公司哪个好点国际重大新闻事件10条

网站建设公司哪个好点,国际重大新闻事件10条,做电子商务系统网站建设,郑州建站软件WPF里TextBox没有placeholder,需要自己实现,本篇博客介绍WPF TextBox实现placeholder,效果如下: 实现技巧是在 TextBox 控件的 Style 中使用触发器(Triggers)来显示和隐藏placeholder文本。xmal代码如下&am…

WPF里TextBox没有placeholder,需要自己实现,本篇博客介绍WPF TextBox实现placeholder,效果如下:

在这里插入图片描述
实现技巧是在 TextBox 控件的 Style 中使用触发器(Triggers)来显示和隐藏placeholder文本。xmal代码如下:

<Window x:Class="WpfApp_TextBox.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfApp_TextBox"mc:Ignorable="d"Title="MainWindow" Height="461" Width="837"><Grid><Canvas><!--设置placeholder--><TextBox x:Name="userName" Width="240" Height="36" FontSize="16" Canvas.Left="20" Canvas.Top="20"><TextBox.Style><Style TargetType="TextBox"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="TextBox"><Grid><TextBox x:Name="textSource" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}}" Background="Transparent" Padding="5"/><TextBlock IsHitTestVisible="False" Text="Enter text here..." Foreground="Gray" Padding="5"><TextBlock.Style><Style TargetType="TextBlock"><Setter Property="Visibility" Value="Collapsed"/><Style.Triggers><DataTrigger Binding="{Binding Text, Source={x:Reference textSource}}" Value=""><Setter Property="Visibility" Value="Visible"/></DataTrigger></Style.Triggers></Style></TextBlock.Style></TextBlock></Grid></ControlTemplate></Setter.Value></Setter></Style></TextBox.Style></TextBox><!--WPF 中的 TextBox 控件可以设置为自动换行。你可以通过设置 TextBox 的 TextWrapping 属性为 Wrap 来实现这个功能。当 TextWrapping 属性设置为 Wrap 时, TextWrapping="Wrap", TextBox 会在文本达到边界时自动换行。--><TextBox Width="200" Height="80" Canvas.Left="20" Canvas.Top="100" VerticalScrollBarVisibility="Auto"TextWrapping="WrapWithOverflow"AcceptsReturn="True"ScrollViewer.CanContentScroll="True"/><TextBox x:Name="UsernameTextBox" Width="200" Height="30" FontSize="18" VerticalAlignment="Top" HorizontalAlignment="Left" VerticalContentAlignment="Center" Canvas.Left="20" Canvas.Top="220"><TextBox.Template><ControlTemplate TargetType="TextBox"><Border Background="White" BorderBrush="Gray" BorderThickness="1"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="Auto" /><ColumnDefinition Width="*" /></Grid.ColumnDefinitions><Image Grid.Column="0" Source="/Assets/Images/user.png" Width="20" Height="20" Margin="5,0,0,0" /><ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" /><!--这里Margin可以调整文字的位置--><TextBlock Grid.Column="1" Text="Enter username..." IsHitTestVisible="False" Foreground="LightGray" Margin="5,2,0,0"><TextBlock.Style><Style TargetType="TextBlock"><Setter Property="Visibility" Value="Collapsed" /><Style.Triggers><DataTrigger Binding="{Binding Text, ElementName=UsernameTextBox}" Value=""><Setter Property="Visibility" Value="Visible" /></DataTrigger></Style.Triggers></Style></TextBlock.Style></TextBlock></Grid></Border></ControlTemplate></TextBox.Template></TextBox><Button Content="Button" HorizontalAlignment="Left" Canvas.Left="20" Canvas.Top="320" VerticalAlignment="Top" Height="41" Width="122" Click="Button_Click"/></Canvas></Grid>
</Window>

需要注意的是,文本的上下边距,如果有蓝湖设计图写起来会很容易,比如上面代码中,使用Margin调整上边距
Font属性

FontSize="18"

TextBlock的Margin属性

<!--这里Margin可以调整文字的位置-->
<TextBlock Grid.Column="1" Text="Enter username..." IsHitTestVisible="False" Foreground="LightGray" Margin="5,2,0,0">

经过这样调整后placeholder的内容才比能竖直居中显示。

http://www.ds6.com.cn/news/122479.html

相关文章:

  • 河南如何做网站seo是什么学校
  • wordpress自动标签页泰安优化关键词排名哪家合适
  • 哪里有给网站做上海关键词推广公司
  • 微网站的优缺点灰色关键词怎么做排名
  • 南京市住房城乡建设委官方网站广州seo推广运营专员
  • 网络安全维护公司简述如何优化网站的方法
  • 网站安全狗服务名中国最新新闻
  • 古典风格网站模板怎么看百度关键词的搜索量
  • 电商网站在线支付怎么做广州seo推广公司
  • 宜春网站建设推广南京seo网站管理
  • mc做地图画网站seo描述是什么
  • wordpress线上聊天插件重庆seo培训
  • 在阿里巴巴做网站佛山seo教程
  • 西安市建设工程信息网官网合肥优化
  • 做网站开发需要的英语水平视频号下载器手机版
  • 太原定制网站开发制作免费建站网站一级
  • 订阅号做微网站需要认证吗网店怎么运营和推广
  • 苏州集团网站设计企业推介网
  • 服务外包的三种形式聊石家庄seo
  • 五莲做网站广告联盟平台哪个好
  • 网站怎么做app吗新浪网今日乌鲁木齐新闻
  • 科技类公司网站设计nba中国官方网站
  • 如何给网站引流百度提交入口网址截图
  • 一流的常州网站优化知名的seo快速排名多少钱
  • 网站和服务器是什么西安seo包年服务
  • 站酷网素材图库海报设计pc端网页设计公司
  • 美国地接公司怎么在中国网站做推广关键词林俊杰歌词
  • 在义乌做电商怎么起步搜索引擎营销seo
  • 如何查询网站空间商百度指数功能模块
  • 网站后台做数据库备份代码抖音营销