簡體   English   中英

如何設置視口的背景色

[英]How to Set Background Color of Viewport

我想在應用頁面(#2B2B2B)中為Viewport控件的背景使用特定的顏色。

<ViewportControl
    x:Name="Viewport"
    Grid.Row="0" Grid.RowSpan="2"
    SizeChanged="Viewport_SizeChanged">
    <Image
        x:Name="Image"
        Stretch="Uniform"
        CacheMode="BitmapCache"
        ManipulationStarted="Viewport_ManipulationStarted"
        ManipulationDelta="Viewport_ManipulationDelta"
        ManipulationCompleted="Viewport_ManipulationCompleted">
    </Image>
</ViewportControl>

ViewportControl添加Background="#2B2B2B"無效。
我的要求是創建一個包含圖像的視口的位圖,並且由於圖像通常不會覆蓋整個視口,因此我想在圖像后方留下一個柔和的深色背景。

WriteableBitmap wb = new WriteableBitmap((int)Viewport.ActualWidth, (int)Viewport.ActualHeight);
wb.Render(Viewport, null);
wb.Invalidate();

您可以將Viewport放在堆棧面板中,並為堆棧面板的背景色賦予顏色,如果顏色也覆蓋了圖像,請使用Zindex。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM