EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

FrameworkElement.FlowDirection Property

Gets or sets the direction that text and other user interface (UI) elements flow within any parent element that controls their layout. This is a dependency property (with an additional attached property usage).

Namespace: System.Windows
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None)] 
public FlowDirection FlowDirection { get; set; }
/** @property */
public FlowDirection get_FlowDirection ()

/** @property */
public void set_FlowDirection (FlowDirection value)

public function get FlowDirection () : FlowDirection

public function set FlowDirection (value : FlowDirection)

<object FlowDirection="FlowDirection"/>
 This property can also be set on classes that are not FrameworkElement derived classes, by the following XAML attached property usage:  < object FrameworkElement.FlowDirection="FlowDirection"/> 

Property Value

The direction that text and other UI elements flow within their parent element, as a value of the enumeration. The default value is LeftToRight.

Identifier field

FlowDirectionProperty

Metadata properties set to true

AffectsMeasure, AffectsParentArrange, Inherits

This property is both a dependency property and an attached property; see Remarks.

This property has a defined common language runtime (CLR) property accessor, and therefore functions as a dependency property, but it is also registered as attached, therefore it can also function as an attached property.

The dependency property usage sets the FlowDirection on this element. Because of property value inheritance, setting FlowDirection on an element can potentially set FlowDirection on all child elements that did not set FlowDirection locally or though other means such as styles.

The attached property usage sets flow direction for that element particularly. This usage is only relevant if the object it was set upon had a FrameworkElement parent element that performs layout upon it, and is itself not a FrameworkElement. For instance, a FrameworkContentElement subclass like Paragraph within the content model of a FrameworkElement can specify its intended flow direction using this attached property syntax: <Paragraph FrameworkElement.FlowDirection="(value)" .../> to specify the flow direction of that particular element as it will be rendered within the parent.

This dependency property inherits property values. If there are child elements without other values for FlowDirection established through local values or styles, then the property system will set the value to be the FlowDirection value of the nearest ancestor element with this value assigned.

This property is not automatically set as part of any application culture information, because an element might contain content that is not necessarily intended to obey the general flow direction implied by the culture information. For more information on globalization considerations, see Globalization for the Windows Presentation Foundation.

This example shows how to programmatically change the FlowDirection property of a FlowDocumentReader.

NoteNote:

This code has been abbreviated. To view the complete code sample, see Changing the FlowDirection Property Sample.

Two Button elements are created, each representing one of the possible values of FlowDirection. When a button is clicked, the associated property value is applied to the contents of a FlowDocumentReader named tf1. The property value is also written to a TextBlock named txt1.

<StackPanel DockPanel.Dock="Top" Orientation="Horizontal" Margin="0,0,0,10">
  <Button Click="LR">LeftToRight</Button>
  <Button Click="RL">RightToLeft</Button>
</StackPanel>

<TextBlock Name="txt1" DockPanel.Dock="Bottom" Margin="0,50,0,0"/>

<FlowDocumentReader>
  <FlowDocument FontFamily="Arial" Name="tf1">
    <Paragraph>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, 
    sed diam nonummy nibh euismod tincidunt ut laoreet dolore 
    magna aliquam erat volutpat.  Ut wisi enim ad minim veniam, 
    quis nostrud exerci tation ullamcorper suscipit lobortis nisl 
    ut aliquip ex ea commodo consequat. Duis autem vel eum iriure.
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
    diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
    aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis 
    nostrud exerci tation ullamcorper suscipit lobortis nisl ut 
    uliquip ex ea commodo consequat. Duis autem vel eum iriure. 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
    diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
    aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis 
    nostrud exerci tation ullamcorper suscipit lobortis nisl ut 
    aliquip ex ea commodo consequat. Duis autem vel eum iriure.
    </Paragraph>
    <Paragraph>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
    diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
    aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis 
    nostrud exerci tation ullamcorper suscipit lobortis nisl ut 
    aliquip ex ea commodo consequat. Duis autem vel eum iriure. 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
    diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
    aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis 
    nostrud exerci tation ullamcorper suscipit lobortis nisl ut 
    aliquip ex ea commodo consequat. Duis autem vel eum iriure. 
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed 
    diam nonummy nibh euismod tincidunt ut laoreet dolore magna 
    aliquam erat volutpat.  Ut wisi enim ad minim veniam, quis 
    nostrud exerci tation ullamcorper suscipit lobortis nisl ut 
    aliquip ex ea commodo consequat. Duis autem vel eum iriure.
    </Paragraph>
  </FlowDocument>
</FlowDocumentReader>

The events associated with the button clicks defined above are handled in a C# code-behind file.

public void LR(object sender, RoutedEventArgs e)
{
    tf1.FlowDirection = FlowDirection.LeftToRight;
    txt1.Text = "FlowDirection is now " + tf1.FlowDirection;
}
public void RL(object sender, RoutedEventArgs e)
{
    tf1.FlowDirection = FlowDirection.RightToLeft;
    txt1.Text = "FlowDirection is now " + tf1.FlowDirection;
}

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Contribuições da comunidade

Mostrar:
© 2014 Microsoft