첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

▶ RichTextBox 클래스 : 선택 문자열의 속성값 설정하기 예제

SetSelectionStringPropertyValue<FontFamily>(richTextBox, FlowDocument.FontFamilyProperty, fontFamily);

SetSelectionStringPropertyValue<double>(richTextBox, FlowDocument.FontSizeProperty, fontSize);

SetSelectionStringPropertyValue<FontWeight>(richTextBox, FlowDocument.FontWeightProperty, fontWeight);

SetSelectionStringPropertyValue<FontStyle>(richTextBox, FlowDocument.FontStyleProperty, fontStyle);

SetSelectionStringPropertyValue<Brush>(richTextBox, FlowDocument.BackgroundProperty, backgroundBrush);

SetSelectionStringPropertyValue<Brush>(richTextBox, FlowDocument.ForegroundProperty, foregroundBrush);

SetSelectionStringPropertyValue<TextAlignment>(richTextBox, FlowDocument.TextAlignmentProperty, textAlignment);

 

728x90

 

RichTextBox 클래스 : 선택 문자열의 속성값 설정하기

using System.Windows;
using System.Windows.Controls;

#region 선택 문자열 속성 값 설정하기 - SetSelectionStringPropertyValue<TValue>(richTextBox, dependencyProperty, propertyValue)

/// <summary>
/// 선택 문자열 속성 값 설정하기
/// </summary>
/// <typeparam name="TPropertyValue">속성 값 타입</typeparam>
/// <param name="richTextBox">RichTextBox 객체</param>
/// <param name="dependencyProperty">DependencyProperty 객체</param>
/// <param name="propertyValue">속성 값</param>
public void SetSelectionStringPropertyValue<TPropertyValue>(RichTextBox richTextBox, DependencyProperty dependencyProperty, TPropertyValue propertyValue)
{
    richTextBox.Selection.ApplyPropertyValue(dependencyProperty, propertyValue);
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요