ViewBox의 서식있는 텍스트 상자를 줄 바꿈하고 너비를 my answer here과 비슷하게 설정하여 확대/축소 기능을 추가 할 수 있습니다.
private int BaseWidth = 1150;
private int BaseHeight = 750;
public int Width
{
get
{
return (int)(BaseWidth * appSettings.Zoom);
}
}
public int Height
{
get
{
return (int)(BaseHeight * appSettings.Zoom);
}
}
당신은 다음과 같은 동작을 얻을 것이다 : 그것은 아마도 뷰 박스의 폭과 높이를 사용하여 일부 조정이 필요할 수 있습니다
폭과 높이로
<Viewbox>
<RichTextBox Width="{Binding Width}" Height="{Binding Height}"/>
</ViewBox>
서식있는 텍스트를 그 배수로 설정하여 UX와 잘 맞 춥니 다. 당신은이 같은 multibinding 사용하여 레이아웃 화면 비율 등의 유지, "배 정상 크기"스케일링을 얻을 수
편집 :
<Grid x:Name="MainViewBoxContainer">
<Viewbox>
<RichTextBox>
<RichTextBox.Width>
<MultiBinding Converter="{StaticResource MultiBindingMultiplier}">
<Binding Path="ActualWidth" ElementName="MainViewBoxContainer"/>
<Binding Path="Zoom"/>
</MultiBinding>
</RichTextBox.Width>
<RichTextBox.Height>
<MultiBinding Converter="{StaticResource MultiBindingMultiplier}">
<Binding Path="ActualHeight" ElementName="MainViewBoxContainer"/>
<Binding Path="Zoom"/>
</MultiBinding>
</RichTextBox.Height>
</RichTextBox>
</Viewbox>
을 어디 multibinding 계산기 :
public class MultiBindingMultiplier : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length > 1)
{
try
{
double value = (double)values[0];
for (int i = 1; i < values.Length; i++)
{
value *= (double)values[i];
}
return value;
}
catch
{
return null;
}
}
return null;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
출처
2016-08-12 09:13:23
Joe
조 대답은 내 문제를 해결하고, 나는 또한이 기능을 달성 할 수있는 다른 방법을 찾는다. [다른 대답] (http://stackoverflow.com/questions/3430629/is-it-possible-to-zoom-the-text-in-a- wpf-richtextbox) –
그게 더 좋은 방법이에요! – Joe