Wpf DataGrid放大/缩小

Muh*_*nan 2 wpf datagrid

我正在使用具有模板列的wpf数据网格.

我只是想为用户提供放大/缩小功能.

任何方式来实现这一目标?

Wal*_*mer 9

下面的示例使用滑块来控制文本块的缩放.

<Window x:Class="ZoomTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Height="300" Width="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Slider Grid.Row="0" Name="_zoom" Minimum="1" Maximum="100" />
        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <Grid>
                <TextBlock Text="DataGrid" Background="Red"/>
                <Grid.LayoutTransform>
                    <ScaleTransform ScaleX="{Binding Path=Value, ElementName=_zoom}" ScaleY="{Binding Path=Value, ElementName=_zoom}" />
                </Grid.LayoutTransform>
            </Grid>
        </ScrollViewer>
    </Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)