3
WPF TextBlock에서 선택한 텍스트의 배경을 강조 표시하거나 설정하려고합니다. 2 개의 텍스트 파일을 메모리에로드하고 diff를 완료 한 다음 WPF 앱에서 디플레이하고 싶다고 가정 해 보겠습니다. 각 줄을 반복 한 다음 텍스트를 텍스트 블록에 추가하고 삭제, 삽입 또는 동일 텍스트를 기반으로 색상을 변경한다고 가정 해보십시오.WPF TextBlock의 텍스트 강조 표시
for (int i = 0; i < theDiffs.Count; i++)
{
switch (theDiffs[i].operation)
{
case Operation.DELETE:
// set color to red on Source control version TextBlock
break;
case Operation.INSERT:
WorkspaceVersion.AppendText(theDiffs[i].text);
// set the background color (or highlight) of appended text to green
break;
case Operation.EQUAL:
WorkspaceVersion.AppendText(theDiffs[i].text);
// Set the background color (highlight) of appended text to yellow
break;
default:
throw new ArgumentOutOfRangeException();
}
}
브릴리언트! 고맙습니다! –