あなたはViewBoxをリッチテキストボックスをラップし、my answer hereに類似の幅を設定することにより、ズーム機能を追加することができます。幅と高さで
<Viewbox>
<RichTextBox Width="{Binding Width}" Height="{Binding Height}"/>
</ViewBox>
:
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);
}
}
あなたはこのような振る舞いを取得します:
![enter image description here](https://i.stack.imgur.com/X54YS.gif)
それはおそらく、ViewBoxを幅と高さを使用して、いくつかの調整が必要になることがありますし、リッチテキストをその倍数に設定することで、UXとのスケーラビリティが向上します。
編集あなたはこのようれる多を使用してレイアウトのアスペクト比などを保ち、「2倍の通常サイズ」のスケーリングを取得することができます:
<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>
の多結合コンバータ:
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