How to use staticresource in .cs
-
i have a RadialGradiantBrush in the app.xaml
<Application.Resources>
<RadialGradientBrush x:Name="RGB1">
<GradientStop Color="AntiqueWhite" Offset="0.0" />
<GradientStop Color="LightSalmon" Offset="0.25" />
<GradientStop Color="LightBlue" Offset="0.75" />
<GradientStop Color="Wheat" Offset="1.0" />
</RadialGradientBrush>
</Application.Resources>I assign it to a background in the generic.xaml
<Canvas x:Name="RightCanvas" Grid.Column="2" Background = "{StaticResource RGB1}"/>
How can i do this in the .cs file
RightCanvas.Background = "{StaticResource RGB1}" as RadialGradiantBrush
? Thank you .
-
i have a RadialGradiantBrush in the app.xaml
<Application.Resources>
<RadialGradientBrush x:Name="RGB1">
<GradientStop Color="AntiqueWhite" Offset="0.0" />
<GradientStop Color="LightSalmon" Offset="0.25" />
<GradientStop Color="LightBlue" Offset="0.75" />
<GradientStop Color="Wheat" Offset="1.0" />
</RadialGradientBrush>
</Application.Resources>I assign it to a background in the generic.xaml
<Canvas x:Name="RightCanvas" Grid.Column="2" Background = "{StaticResource RGB1}"/>
How can i do this in the .cs file
RightCanvas.Background = "{StaticResource RGB1}" as RadialGradiantBrush
? Thank you .
RightCanvas.Background = Application.Current.Resources["RGB1"] as RadialGradientBrush;
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
RightCanvas.Background = Application.Current.Resources["RGB1"] as RadialGradientBrush;
Mark Salsbery Microsoft MVP - Visual C++ :java:
Thanks Great, I have my brushes in app.xaml and now can access them from xaml or cs ! But now the designer doesnt work :( Error HRESULT E_FAIL has been returned from a call to a COM component. vs2008
-
Thanks Great, I have my brushes in app.xaml and now can access them from xaml or cs ! But now the designer doesnt work :( Error HRESULT E_FAIL has been returned from a call to a COM component. vs2008
daveyerwin wrote:
But now the designer doesnt work
Since the Silverlight XAML designer is only partially implemented in VS, it can be "challenging" to find the offending code or markup :)
Mark Salsbery Microsoft MVP - Visual C++ :java: