--- lang: ja-jp breaks: true --- # WPF ウィンドウ内のコンテンツをマウスホイールでズームする機能 2021-04-28 > UI Scaling (UI Zooming) with WPF > https://docs.microsoft.com/ja-jp/archive/blogs/ivo_manolov/ui-scaling-ui-zooming-with-wpf > https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Components.PostAttachments/00/05/29/93/62/ScalableUI.zip ```xaml= ~・・・~ <DockPanel Grid.Column="0" Grid.ColumnSpan="2" LastChildFill="True"> <DockPanel.LayoutTransform> <ScaleTransform CenterX="0" CenterY="0" ScaleX="{Binding ElementName=uiScaleSlider,Path=Value}" ScaleY="{Binding ElementName=uiScaleSlider,Path=Value}" /> </DockPanel.LayoutTransform> ~・・・~ </DockPanel> <Slider x:Name="uiScaleSlider" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" ToolTip="Determines the UI scale factor. Double-click to revert scaling back to 100%." Height="100" Value="1" Minimum="0.1" Maximum="10.0" Orientation="Vertical" Ticks="1" IsSnapToTickEnabled="False" TickPlacement="BottomRight" AutoToolTipPlacement="BottomRight" AutoToolTipPrecision="2" /> ``` ```csharp= /// <summary> /// The user can scale up/down the UI by using the mouse wheel while holding down /// the Ctrl key. /// </summary> protected override void OnPreviewMouseWheel(MouseWheelEventArgs args) { base.OnPreviewMouseWheel(args); if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) { uiScaleSlider.Value += (args.Delta > 0) ? 0.1 : -0.1; } } ```   ###### tags: `WPF` `ScalableUI` `DockPanel` `ScaleTransform` `XAML`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up