Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight 3
 ElementStyle Property

  Switch on low bandwidth view
This page is specific to
Microsoft Silverlight 3

Other versions are also available for the following:
.NET Framework Class Library for Silverlight
DataGridBoundColumn..::.ElementStyle Property

Gets or sets the style that is used when rendering the element that the column displays for a cell that is not in editing mode.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)
Visual Basic (Declaration)
Public Property ElementStyle As Style
    Get
    Set
Visual Basic (Usage)
Dim instance As DataGridBoundColumn
Dim value As Style

value = instance.ElementStyle

instance.ElementStyle = value
C#
public Style ElementStyle { get; set; }
XAML Property Element Usage
<object>
  <object.ElementStyle>
    inlineStyle
  </object.ElementStyle>
</object>
XAML Attribute Usage
<object ElementStyle="styleReference"/>

XAML Values

object

See Remarks in DataGridBoundColumn.

inlineStyle

A single Style object element. The TargetType used for this Style depends on the Type of the element. This style can define setters for any properties of the element that can be styled. See Inline Styles and Templates.

styleReference

A StaticResource reference to a Style that defines the appearance of the column. This style should use the TargetType of the element.

Property Value

Type: System.Windows..::.Style
The style that is used when rendering a display-only element. The default is nullNothingnullptra null reference (Nothing in Visual Basic).

The following code example demonstrates how to set the ElementStyle property in XAML. This example is part of a larger example available in the DataGrid class overview.

<data:DataGrid x:Name="dataGrid4" 
    Height="160" Margin="0,5,0,10" 
    RowHeight="40" AutoGenerateColumns="False" >    
    <data:DataGrid.Columns>
        <data:DataGridTextColumn 
            Header="First Name" 
            Width="SizeToHeader"
            Binding="{Binding FirstName}" 
            FontSize="20" />
        <data:DataGridTextColumn 
            Header="Last Name" 
            Width="SizeToCells"
            Binding="{Binding LastName}" 
            FontSize="20" />
        <data:DataGridTextColumn 
            Header="Address"
            Width="150"
            Binding="{Binding Address}" >
            <data:DataGridTextColumn.ElementStyle>
                <Style TargetType="TextBlock">
                    <Setter Property="TextWrapping" Value="Wrap"/>
                </Style>
            </data:DataGridTextColumn.ElementStyle>
            <data:DataGridTextColumn.EditingElementStyle>
                <Style TargetType="TextBox">
                    <Setter Property="Foreground" Value="Blue"/>
                </Style>
            </data:DataGridTextColumn.EditingElementStyle>
        </data:DataGridTextColumn>
        <data:DataGridCheckBoxColumn 
            Header="New?" 
            Width="40"
            Binding="{Binding IsNew}" />
        <data:DataGridCheckBoxColumn 
            Header="Subscribed?" 
            Width="Auto"
            Binding="{Binding IsSubscribed}" 
            IsThreeState="True" />
    </data:DataGrid.Columns>
</data:DataGrid>

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker