Last active
November 7, 2021 18:42
-
-
Save CheetahChrome/becc3cebd5d6774d27e26ad120db9290 to your computer and use it in GitHub Desktop.
WPF Resize Text In Control MouseWheelScroll Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private double _MainFontSize; | |
public double MainFontSize | |
{ | |
get => _MainFontSize; | |
set { _MainFontSize = value; OnPropertyChanged(nameof(MainFontSize)); } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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