0

現在、コントロールを画面上または画面外にスライドさせるアプリケーションを作成しようとしています。基本的に、左右にページがあるモバイル デスクトップを想像してみてください。2 ページしかないことを除けば、それが私のアプリケーションの外観です。私は現在、ストーリーボードとItemsControl、および画面を離れるページのRenderTargetBitmapを使用してページをスライドさせています。問題は、RenderTargetBitmap が少し引き伸ばされたように見えるか、コントロール上のすべてのテキストが突然太字になったかのように見えることです。下の画像で太字の効果を確認できます。

大胆な問題

これは、ビットマップとしてレンダリングされていない場合のページの外観です。

標準

右からスライドインするもう 1 つのコントロールには、このような問題はありません。この問題が発生するのは常に RenderTargetBitmap です。この関数でビットマップを生成します。

Public Function RenderBitmap(Element As FrameworkElement) As RenderTargetBitmap
    Dim TTopLeft As Double = 0
    Dim TTopRight As Double = 0
    Dim TWidth As Integer = CInt(Element.ActualHeight)
    Dim THeight As Integer = CInt(Element.ActualWidth)
    Dim DPIX As Double = 96.0
    Dim DPIY As Double = 96.0

    Dim PxlFormat As PixelFormat = PixelFormats.Default
    Dim ElementBrush As New VisualBrush(Element)
    Dim Visual As New DrawingVisual()
    Dim DC As DrawingContext = Visual.RenderOpen()

    DC.DrawRectangle(ElementBrush, Nothing, New Rect(TTopLeft, TTopRight, TWidth, THeight))
    DC.Close()

    Dim ExportBitmap As New RenderTargetBitmap(TWidth, THeight, DPIX, DPIY, PxlFormat)
    ExportBitmap.Render(Visual)
    Return ExportBitmap
End Function

長方形に表示されるもの:

    Dim rtb As RenderTargetBitmap = RenderBitmap(PageViewer)
    RectangleVisual.Fill = New ImageBrush(BitmapFrame.Create(rtb)) With {.Stretch = Stretch.Fill}

XAML の四角形は次のとおりです。

    <Border x:Name="BorderVisual" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Rectangle x:Name="RectangleVisual"/>
        <Border.RenderTransform>
            <TranslateTransform/>
        </Border.RenderTransform>
        <Border.CacheMode>
            <BitmapCache EnableClearType="True" SnapsToDevicePixels="True" RenderAtScale="1.0"/>
        </Border.CacheMode>
    </Border>

true に設定する必要のあるプロパティがありませんか? 優良物件?何も見つかりません。ビットマップを作成するために使用すべきより良い方法はありますか?

ありがとう!

編集1:使用Stretch = None

ここに画像の説明を入力

編集 2: 問題は解決しました。関数の高さと幅が間違った方向にありました...問題は何週間も私を悩ませてきました。時には重要なささいなこと!

4

0 に答える 0