C#(wpf)迷你词典

本周利用空余时间做的一个单词查询软件(C#(Wpf)-WebService),目前只支持中英文查词,同义词、例句、发音。

未激活状态

 

WebService:http://fy.webxml.com.cn/webservices/EnglishChinese.asmx

很简单的一个东西,主要的还是熟悉wpf的样式与模板

圆角窗体:

//圆角有阴影的窗体
<
Style x:Key="Noresize_Window" TargetType="{x:Type Window}"> <Setter Property="AllowsTransparency" Value="true"/> <Setter Property="Background" Value="White"/> <Setter Property="ResizeMode" Value="NoResize"/> <Setter Property="WindowStyle" Value="None"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Window}"> <Grid Margin="10"> <Rectangle Fill="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" RadiusX="1" RadiusY="1"> <Rectangle.Effect> <DropShadowEffect BlurRadius="6" ShadowDepth="0"/> </Rectangle.Effect> </Rectangle> <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Margin}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="5"> <ContentPresenter /> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

//没有边框的文本框
<
Style x:Key="NoBorder_TestBox" TargetType="{x:Type TextBox}"> <Setter Property="SnapsToDevicePixels" Value="True" /> <Setter Property="OverridesDefaultStyle" Value="True" /> <Setter Property="KeyboardNavigation.TabNavigation" Value="None" /> <Setter Property="FocusVisualStyle" Value="{x:Null}" /> <Setter Property="MinWidth" Value="120" /> <Setter Property="MinHeight" Value="20" /> <Setter Property="AllowDrop" Value="true" /> <Setter Property="FontSize" Value="14"></Setter> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBoxBase}"> <Border Name="Border" CornerRadius="2" Padding="2" BorderThickness="0"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal" /> <VisualState x:Name="Disabled"> <Storyboard> <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background). (SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledControlLightColor}" /> </ColorAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="ReadOnly"> <Storyboard> <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="(Panel.Background). (SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="0" Value="{StaticResource DisabledControlDarkColor}" /> </ColorAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="MouseOver" /> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <ScrollViewer Margin="0" x:Name="PART_ContentHost" VerticalAlignment="Center" /> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style>
原文地址:https://www.cnblogs.com/liuxiaobo93/p/3895459.html