为了账号安全,请及时绑定邮箱和手机立即绑定

列表框导出到图片

列表框导出到图片

C#
UYOU 2021-10-23 16:41:57
我有一个关于将 ListBox 导出到图像文件的问题。我在 XAML 中有这个代码: <ListBox SelectedItem="{Binding SelectedObject}"                  PreviewMouseMove="ListBox_PreviewMouseMove"                 PreviewMouseDown="ListBox_PreviewMouseDown" Name="platno">            <ListBox.Template>                <ControlTemplate>                    <Border>                        <Border.Background>                            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" Opacity=".3">                                <GradientStop Color="White" Offset="0"/>                                <GradientStop Color="GhostWhite" Offset="1"/>                            </LinearGradientBrush>                        </Border.Background>                        <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible" x:Name="scroll">                            <Border>                                <!-- Pozadí s mřížkou -->                                <Border.Background>                                    <VisualBrush TileMode="Tile"                                    Viewport="0,0,50,50" ViewportUnits="Absolute"                                     Viewbox="0,0,50,50" ViewboxUnits="Absolute">                                        <VisualBrush.Visual>                                            <Rectangle Stroke="Darkgray" StrokeThickness="1" Height="50" Width="50"                                        StrokeDashArray="5 3"/>                                        </VisualBrush.Visual>                                    </VisualBrush>                                </Border.Background>                                <ItemsPresenter/>                            </Border>                        </ScrollViewer>                    </Border>                </ControlTemplate>            </ListBox.Template>有了这个视觉。现在我的问题。我在后面有一个代码来导出中央面板,而程序的顶部和左侧没有面板。我在 ListBox 中导出对象时遇到问题。当我tryed这部分导出到图片,我只给放大场景的一部分像这样和方法的背后
查看完整描述

1 回答

?
饮歌长啸

TA贡献1951条经验 获得超3个赞

如果你不想缩放,你应该在 RenderTargetBitmap 中使用 96 dpi:

RenderTargetBitmap rb = new RenderTargetBitmap(Convert.ToInt32(vm.AreaWidth), Convert.ToInt32(vm.AreaHeight), 96d, 96d, PixelFormats.Pbgra32);



查看完整回答
反对 回复 2021-10-23
  • 1 回答
  • 0 关注
  • 155 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信