Several WPF styles are used for self-preparation and several wpf styles are used for forgetting.

Source: Internet
Author: User

Several WPF styles are used for self-preparation and several wpf styles are used for forgetting.

Sample UI effects:

 

Code:

<! -- Focus style, pale blue dotted line with a margin of 2, 1 pixel width -->
<Style x: Key = "FocusVisual">
<Setter Property = "Control. Template">
<Setter. Value>
<ControlTemplate>
<Rectangle Margin = "2" StrokeThickness = "1" Stroke = "LightBlue" StrokeDashArray = "1 2"/>
</ControlTemplate>
</Setter. Value>
</Setter>
</Style>

<! -- Tab container style and unlimited tab style -->
<Style x: Key = "TabControlStyle" TargetType = "{x: Type TabControl}">
<Setter Property = "Template">
<Setter. Value>
<ControlTemplate TargetType = "{x: Type TabControl}">
<Grid ClipToBounds = "true" SnapsToDevicePixels = "true" KeyboardNavigation. TabNavigation = "Local">
<Grid. ColumnDefinitions>
<ColumnDefinition x: Name = "ColumnDefinition0"/>
<ColumnDefinition x: Name = "ColumnDefinition1" Width = "0"/>
</Grid. ColumnDefinitions>
<Grid. RowDefinitions>
<RowDefinition x: Name = "RowDefinition0" Height = "Auto"/>
<RowDefinition x: Name = "RowDefinition1" Height = "*"/>
</Grid. RowDefinitions>
<TabPanel x: Name = "HeaderPanel" Grid. column = "0" IsItemsHost = "true" Margin = "0" Background = "# FF212121" Grid. row = "0"/>
<Border x: Name = "ContentPanel" BorderThickness = "0" Background = "# ff0000242" Grid. Column = "0" Grid. Row = "1">
<ContentPresenter x: Name = "PART_SelectedContentHost" ContentSource = "SelectedContent" Margin = "0"/>
</Border>
</Grid>
</ControlTemplate>
</Setter. Value>
</Setter>
</Style>
<! -- Tab label style, with a width of 120 and a height of 40 -->
<Style x: Key = "TabItemStyle" TargetType = "{x: Type TabItem}">
<Setter Property = "Template">
<Setter. Value>
<ControlTemplate TargetType = "{x: Type TabItem}">
& Lt; Grid Width = "120" Height = "40" & gt;
<Border x: Name = "Border" BorderThickness = "0" CornerRadius = "0">
<ContentPresenter x: Name = "ContentSite"
VerticalAlignment = "Center"
HorizontalAlignment = "Center"
ContentSource = "Header"
Margin = "12,6, 12,6"/>
</Border>
</Grid>
<ControlTemplate. Triggers>
<Trigger Property = "IsSelected" Value = "True">
<Setter TargetName = "Border" Property = "Background" Value = "# ff0000242"/>
</Trigger>
<Trigger Property = "IsSelected" Value = "False">
<Setter TargetName = "Border" Property = "Background" Value = "# FF212121"/>
</Trigger>
</ControlTemplate. Triggers>
</ControlTemplate>
</Setter. Value>
</Setter>
</Style>

<! -- Define the button style, the simplest solid color button, and change the color. -->
<Style TargetType = "Button">
<Setter Property = "Foreground" Value = "White"/>
<Setter Property = "Template">
<Setter. Value>
<ControlTemplate TargetType = "Button">
<Border x: Name = "back" CornerRadius = "5" BorderBrush = "# FF03A9F4" BorderThickness = "2" Background = "# FF03A9F4">
<ContentPresenter x: Name = "content" HorizontalAlignment = "Center" verticalignment = "Center" Content = "{TemplateBinding Content}">
</ContentPresenter>
</Border>
<! -- Trigger -->
<ControlTemplate. Triggers>
<! -- Move the mouse in and out -->
<Trigger Property = "IsMouseOver" Value = "True">
<Setter TargetName = "back" Property = "Background" Value = "# FF0277BD"/>
<Setter TargetName = "back" Property = "BorderBrush" Value = "# FF0277BD"/>
</Trigger>
<! -- Click the button to pop up -->
<Trigger Property = "IsPressed" Value = "True">
<Setter TargetName = "back" Property = "BorderBrush" Value = "# FF0277BD"/>
<Setter TargetName = "back" Property = "Background" Value = "#00000000"/>
</Trigger>
</ControlTemplate. Triggers>
</ControlTemplate>
</Setter. Value>
</Setter>
</Style>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.