Metro风格应用中的简单径向渐变背景

Metro风格应用中的简单径向渐变背景

本文介绍了Metro风格应用中的简单径向渐变背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在XAML / C#Metro-Style应用程序中绘制径向渐变背景(也能够更改其颜色)的简单方法是什么?
是否使用DirectX?我尝试查看一些适用于Windows 8 Consumer Preview的SharpDX示例,但未能编译它们。还没有找到在Windows 8上的C#中使用DX的其他示例。
有什么想法吗?

What would be a simple way of drawing a radial gradient background (also being able to change it's color) in a XAML/C# Metro-Style App ?Is using DirectX an option ? I tried looking at some SharpDX samples for Windows 8 Consumer Preview but failed to compile them. Haven't found any other samples of using DX in C# on Windows 8.Any ideas ?

推荐答案

RadialGradientBrush有尚未添加到XAML堆栈中。您可以使用WriteableBitmapEx自己将渐变绘制到WriteableBitmap上,然后使用Image或ImageBrush来显示渐变-尽管如果要使用多个形状不同的渐变,这可能会非常慢。

RadialGradientBrush has not been added to the XAML stack yet. You can use WriteableBitmapEx to draw the gradient to a WriteableBitmap yourself and then use an Image or ImageBrush to display it - although that could be prohibitively slow if you have many elements that you want to use differently shaped gradients on.

您可以只使用在Photoshop或Paint.NET中创建的常规图像。

You could just use a regular image created in Photoshop or Paint.NET.

使用DirectX可能太复杂了,并不是很必要,但是您可以将DirectX与XAML混合使用。如果您真的想去那里-您可能需要使用SurfaceImageSource。有关MSDN的基本介绍,请或检查SharpDX示例。您可能还希望使用Direct2D渲染到该表面,因此需要混合很多技术。

Using DirectX might be too complicated and not really necessary, but you can mix DirectX with XAML. If you really want to go there - you would probably need to use SurfaceImageSource. There is a basic introduction on MSDN here or check a SharpDX sample here. You would probably also want to use Direct2D to render to that surface, so there are quite a few technologies you would need to mix.

这篇关于Metro风格应用中的简单径向渐变背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 14:08