Style With Data Trigger : Style « Windows Presentation Foundation « C# / CSharp Tutorial

Home
C# / CSharp Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statement
5.String
6.struct
7.Class
8.Operator Overload
9.delegate
10.Attribute
11.Data Structure
12.Assembly
13.Date Time
14.Development
15.File Directory Stream
16.Preprocessing Directives
17.Regular Expression
18.Generic
19.Reflection
20.Thread
21.I18N Internationalization
22.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » Windows Presentation Foundation » Style 
24.66.5.Style With Data Trigger
<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <StackPanel.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="FontSize" Value="24" />
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="Margin" Value="24" />

            <Style.Triggers>
                <DataTrigger Binding="{Binding ElementName=txtbox, 
                                               Path=Text.Length}"
                             Value="0">
                    <Setter Property="IsEnabled" Value="False" />
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </StackPanel.Resources>

    <TextBox Name="txtbox" HorizontalAlignment="Center" 
             Width="2in" Margin="24" />

    <Button>
        Button Number 1
    </Button>
</StackPanel>
WPF Style With Data Trigger
24.66.Style
24.66.1.Double value as the Font sizeDouble value as the Font size
24.66.2.FontFamily resource constantFontFamily resource constant
24.66.3.Styles With Same KeysStyles With Same Keys
24.66.4.Setter With Binding to SliderSetter With Binding to Slider
24.66.5.Style With Data TriggerStyle With Data Trigger
24.66.6.Styles With Target TypesStyles With Target Types
24.66.7.Style With Multiple ElementsStyle With Multiple Elements
24.66.8.Style With Multiple ButtonsStyle With Multiple Buttons
24.66.9.Style With ResourceStyle With Resource
24.66.10.Style With Property ElementStyle With Property Element
24.66.11.Style With TriggersStyle With Triggers
24.66.12.Style Slider: Background, IsSnapToTickEnabled, AutoToolTipPlacement, TickFrequencyStyle Slider: Background, IsSnapToTickEnabled, AutoToolTipPlacement, TickFrequency
24.66.13.Normal: Origin at upper leftNormal: Origin at upper left
24.66.14.Stroke Start Line CapStroke Start Line Cap
24.66.15.Property TriggerProperty Trigger
24.66.16.Using a Style resourceUsing a Style resource
24.66.17.Sharing a StyleSharing a Style
24.66.18.Ignore an Implicit Style by setting Style to NullIgnore an Implicit Style by setting Style to Null
24.66.19.Set a Style ProgrammaticallySet a Style Programmatically
24.66.20.extends StyleSelector to create your own style selectorextends StyleSelector to create your own style selector
24.66.21.The default GroupStyle indents the items in a groupThe default GroupStyle indents the items in a group
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.