PC Review


Reply
Thread Tools Rate Thread

Adding gradientbrush to Hello World application

 
 
Alex. O. Koranteng
Guest
Posts: n/a
 
      23rd Jun 2009
I am getting started with Sliverlight 2.0 and created my first HelloWorld app
following the steps outlined from the Hands-On-labs documentation. The
solution works but it required me to add gradientbrush per the following

Open other supported browsers for Silverlight and access the same URL and
check that the application still works.
12. You may also open the SL2Demo solution in Expression Blend 2 SP1 and add
a gradient brush to the canvas. To do this, from within Visual Studio you can
right-click on a XAML file and choose “Open in Expression Blend” which will
open the solution in Expression Blend. Try to add a header to the screen as
shown below when tested:

I performed the above steps but need help on how accomplish the above.

Below is my code for the Page.XAML.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SilverlightApplication1
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}

private void buttonHello_Click(object sender, RoutedEventArgs e)
{
this.txtSayHello.Text = "Hello, " + this.txtName.Text;
}
}
}

Below is the code for my Page.XAMl

<UserControl x:Class="SilverlightApplication1.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="Bisque" >

<Canvas>
<TextBlock Text="Enter a Name" Canvas.Left="64" Canvas.Top="55"/>
<TextBox x:Name="txtName" Canvas.Left="180" Canvas.Top="55"
Height="25" Width="100"/>
<Button x:Name="buttonHello" Canvas.Left="120" Canvas.Top="105"
Width="100" Content="Say Hello" Click="buttonHello_Click"/>
<TextBlock x:Name="txtSayHello" Canvas.Left="100"
Canvas.Top="150"/>
</Canvas>
</Grid>




Any suggestions will be appreciated





 
Reply With Quote
 
 
 
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      24th Jun 2009
Hi Alex,

The Expression Blend is a designer. All actions we do in the Blend can be
achieved by the directly modifying the Page.xaml file. To assign a gradient
brush to the canvas, we can use the following xaml file,

<UserControl x:Class="SL2Hello.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Canvas>
<Canvas.Background>
<LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
<GradientStop Color="White" Offset="0.0"></GradientStop>
<GradientStop Color="LimeGreen"
Offset="0.5"></GradientStop>
<GradientStop Color="Green" Offset="1.0"></GradientStop>
</LinearGradientBrush>
</Canvas.Background>
<TextBlock Text="Enter a Name" Canvas.Left="64"
Canvas.Top="55"/>
<TextBox x:Name="txtName" Canvas.Left="180" Canvas.Top="55"
Height="25" Width="100"/>
<Button x:Name="buttonHello" Canvas.Left="120" Canvas.Top="105"
Width="100"
Content="Say Hello" Click="buttonHello_Click"/>
<TextBlock x:Name="txtSayHello" Canvas.Left="100"
Canvas.Top="150"/>
</Canvas>
</Grid>
</UserControl>


Best regards,
Colbert Zhou
Microsoft Newsgroup Support Team

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Real-World Sample Application? (PeteCresswell) Microsoft Dot NET 19 27th Jun 2008 12:22 AM
WORLD TOURSIM WORLD TRAVEL WORLD PACKAGE TAJMAHAL TEMPLE Microsoft Dot NET 0 7th Apr 2008 04:32 PM
GradientBrush, Transparency and ContainerControl! zden Irmak Microsoft Dot NET Framework Forms 4 30th Jun 2006 03:05 PM
Application Data/Free World Dialup?? OM Windows XP Help 1 3rd Dec 2005 11:10 PM
Server Error in '/Hello World' Application =?Utf-8?B?U2Vhbg==?= Microsoft ASP .NET 1 20th Jul 2004 11:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:26 AM.