'宣言 Public ReadOnly Property TextAlignmentResolved As TextAlignment
public TextAlignment TextAlignmentResolved {get;}
Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) Me.textEditor1.ClearValue(XamTextEditor.TextAlignmentProperty) Me.textEditor1.HorizontalContentAlignment = Windows.HorizontalAlignment.Right ' TextAlignment will return Left which is the default value of the property. Debug.WriteLine("TextAlignment = " & Me.textEditor1.TextAlignment.ToString()) ' TextAlignmentResolved will return Right. This is because TextAlignment is not ' set on the text editor itself. In such a case the resolved text alignment will ' be based on the HorizontalContentAlignment setting. Debug.WriteLine("TextAlignmentResolved = " & Me.textEditor1.TextAlignmentResolved.ToString()) End Sub
public void button1_Click( object sender, RoutedEventArgs e ) { this.textEditor1.ClearValue( XamTextEditor.TextAlignmentProperty ); this.textEditor1.HorizontalContentAlignment = HorizontalAlignment.Right; // TextAlignment will return Left which is the default value of the property. Debug.WriteLine( "TextAlignment = " + this.textEditor1.TextAlignment ); // TextAlignmentResolved will return Right. This is because TextAlignment is not // set on the text editor itself. In such a case the resolved text alignment will // be based on the HorizontalContentAlignment setting. Debug.WriteLine( "TextAlignmentResolved = " + this.textEditor1.TextAlignmentResolved ); }