【发布时间】:2014-02-08 05:50:18
【问题描述】:
我想在我的应用页面 (#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();
【问题讨论】:
-
嗯,根据文档,背景是一个有效的属性,也许尝试将 alpha 通道添加到您的颜色中?喜欢
Background="#FF2B2B2B"或者只是在图片后面放一些你知道可以着色的东西,比如Rectangle或Background -
好吧,在视口背景中添加 alpha 通道没有任何效果,将图像控件放置在视口内的网格中以及将网格的背景设置为颜色也没有效果。
-
你认为 alpha 值是 50/50,而我认为 Grid 必须是
工作....除了实际上背景属性应该工作,我还没有找到任何类型的模板。 -
同意。同时我所做的是更改 LayoutRoot 的背景,并切换一个控件的可见性以达到相同的效果。如果我找到解决方案,我会继续研究并发布。
标签: c# xaml windows-phone-7 windows-phone-8 bitmap