Difference between revisions of "Silverlight"

From Richard's Wiki
Jump to: navigation, search
Line 12: Line 12:
 
                 ShadowDepth="10" />
 
                 ShadowDepth="10" />
 
</code>
 
</code>
** To use:
+
** To use (in xaml):
 
<code>
 
<code>
 
  Effect="{StaticResource DropShadow}"
 
  Effect="{StaticResource DropShadow}"
 +
</code>
 +
** To use (in .cs):
 +
<code>
 +
  control.Effect = Application.Current.Resources["DropShadow"] as System.Windows.Media.Effects.Effect
 
</code>
 
</code>
 
* To get position of a UIElement:
 
* To get position of a UIElement:

Revision as of 20:29, 20 March 2010

<DropShadowEffect x:Key="DropShadow"  
               BlurRadius="15" 
               Color="Black" 
               Direction="320"
               Opacity="1.0"
               ShadowDepth="10" />

    • To use (in xaml):

Effect="{StaticResource DropShadow}"

    • To use (in .cs):

 control.Effect = Application.Current.Resources["DropShadow"] as System.Windows.Media.Effects.Effect

  • To get position of a UIElement:

// Obtain transform information based off root element
UIElement element = this as UIElement;
GeneralTransform gt = element.TransformToVisual(Application.Current.RootVisual);
// Find the four corners of the element
Point topLeft = gt.Transform(new Point(0, 0));
Point topRight = gt.Transform(new Point(element.RenderSize.Width, 0));
Point bottomLeft = gt.Transform(new Point(0, element.RenderSize.Height));
Point bottomRight = gt.Transform(new Point(element.RenderSize.Width, element.RenderSize.Height));

Silverlight Control Libraries