locked
[UWP][Xaml]RadialGradientBrush options? RRS feed

  • Question

  • Error RadialGradientBrush is not supported in a Windows Universal project.

    As we know RadialGradientBrush is not supported, but It is available under WinRT. How can I include WinRT in my project so I could call in xaml and C# code? Logically I don't see any problem! How sample will look like?

    Best regards

     

    Agha Khan

    Wednesday, February 3, 2016 6:34 AM

Answers

  • That error is expected. RadialGradientBrush is not available in Windows.UI.Xaml.

    I'm not sure what you mean by "It is available under WinRT". As Chuck says, Win2D has a RadialGradientBrush, but you cannot mix Win2D and Xaml that directly. You can host a Win2D canvas in your Xaml tree, but you can't use Win2D brushes as Xaml brushes.

    Depending on your goal you may be able to create a radial gradiant bitmap and use that in an ImageBrush.
    Wednesday, February 3, 2016 5:53 PM

All replies

  • RadialGradientBrush is supported by Direct2D, which is supported by UWP. What namespace in particular are you using that gives you an error? Is it System.Windows.Media?

    Have you looked at Win2D?


    Wednesday, February 3, 2016 7:05 AM
  • I looked Win2D which is just beautiful, but unable to change my project to Win2D because this project is at final stage. Thanks for advise. This thread is talking about taking advantages of WinRT and I was interested going to that route. You already answered same question where we were talking about C# or UWP. It is very easy reproduce this error. Just create blank application and in resource place few lines of code. WOW you got the error. 

    <Page
        x:Class="App1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App1"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
        <Page.Resources>
            <RadialGradientBrush x:Key="New_Gradient_53"
                                 Center="88.41,725.41"
                                 RadiusX="251.62"
                                 RadiusY="251.62">
                <GradientStop Offset="0"
                              Color="#fff" />
                <GradientStop Offset="0.11"
                              Color="#fff" />
                <GradientStop Offset="1"
                              Color="#191919" />
                <RadialGradientBrush.Transform>
                    <TransformGroup>
                        <TranslateTransform X="24.88"
                                            Y="-549.66" />
                    </TransformGroup>
                </RadialGradientBrush.Transform>
            </RadialGradientBrush>
        </Page.Resources>
    
        <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        </Grid>
    </Page>
    

    No it is not System.Windows.Media error and I am thinking to add RadialGradientBrush  with help of WinRT.  Logically I don't see any  problem. It would be nice if Microsoft/you provide simple sample. Your help is very much appriciated.


    Agha Khan

    Wednesday, February 3, 2016 4:29 PM
  • That error is expected. RadialGradientBrush is not available in Windows.UI.Xaml.

    I'm not sure what you mean by "It is available under WinRT". As Chuck says, Win2D has a RadialGradientBrush, but you cannot mix Win2D and Xaml that directly. You can host a Win2D canvas in your Xaml tree, but you can't use Win2D brushes as Xaml brushes.

    Depending on your goal you may be able to create a radial gradiant bitmap and use that in an ImageBrush.
    Wednesday, February 3, 2016 5:53 PM
  • Hello Rob,

    We are readying to upgrade/migrate oyr app from silverlight to UWP. But we cannot find any news about radialgradientbrush in the upcomming aniversary update. Do you have information about this?

    Our application relies heavily upon this element, it is there interesting to know if this is going to arrive?

    Because we cannot find anything in documentation

    Thanks


    • Edited by JOTM123 Monday, July 25, 2016 10:04 AM
    Monday, July 25, 2016 10:00 AM
  • should the answer be updated now https://blogs.windows.com/buildingapps/2016/09/12/creating-beautiful-effects-for-uwp/#mjq2IIFvcLPHCLrs.97 I am not able to find news about the xaml integration or use of radial gradient brush ?
    Thursday, September 29, 2016 9:56 PM