Skip to content

Instantly share code, notes, and snippets.

@CheetahChrome
Last active November 7, 2021 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheetahChrome/becc3cebd5d6774d27e26ad120db9290 to your computer and use it in GitHub Desktop.
Save CheetahChrome/becc3cebd5d6774d27e26ad120db9290 to your computer and use it in GitHub Desktop.
WPF Resize Text In Control MouseWheelScroll Event
private void MouseWheelScroll(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
return;
var delta = (e.Delta > 0) ? 2 : -2;
var change = VM.MainFontSize + delta;
if (change < 8)
change = 8;
VM.MainFontSize = change;
}
private double _MainFontSize;
public double MainFontSize
{
get => _MainFontSize;
set { _MainFontSize = value; OnPropertyChanged(nameof(MainFontSize)); }
}
<TabItem Header="Tree" Width="100" Height="40">
<TreeView x:Name="tView" HorizontalAlignment="Stretch" FontSize="{Binding MainFontSize}" PreviewMouseWheel="MouseWheelScroll" />
</TabItem>
<TabItem Header="Text" Width="100" Height="40">
<TextBox Text="{Binding JSONText}" PreviewMouseWheel="MouseWheelScroll" FontSize="{Binding MainFontSize}" />
</TabItem>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment