(X) Hide this SilverlightShow next training events: Secure & Personalize Your Silverlight App with WCF RIA Services. May 25th, 10 am PST. Sign up
XNA for Windows Phone 7 - a 3 day training by MCC Peter Kuhn. June 1-3, 9 am - 1.30 pm PST. Sign up early-bird for $199.
Skip Navigation LinksHome / Articles / Learn / Tips and Tricks

Tips and Tricks

+
Page 
Items Resolution

  • 4 comments  /  posted by  Nikolay Raychev  on  Jun 17, 2008 (more than a year ago)

    Introduction

    When you are making a web request from a Silverlight application the cookies associated with the current browser-server session are automatically sent within each request.

    A common scenario is when you have a web site with some kind of a cookie driven authentication implemented and a Silverlight application within your web site that shows different content depending on whether the user is logged in or not. The Silverlight application may use some resources on the server, which are accessible only to authenticated users. The good thing is that if you are logged in the web site and make requests from the Silverlight application the server “knows” that your requests come from an authenticated user. You do not need to login both on the web site and the Silverlight application.

    Example

    I made a simple example to test if all this stuff really works. I just want to have a simple web site with Form authentication and a Silverlight application which uses a resource from the server. The resource behaves differently when the user is logged in and when not. I won’t describe how I created the web site and the authentication system because you are not limited about the server technology. Currently it is ASP.NET web site with the standard ASP.NET membership. But you can also make it with PHP for example.

    Share


  • 4 comments  /  posted by  Ivan Dragoev  on  Jun 12, 2008 (more than a year ago)

    This article is compatible with the latest version of Silverlight.


    Introduction

    In the first article I showed you how to animate ListBox items in Silverlight. Then, to make all the animation the way I wanted, I used some code and hardcoded names of the Storyboards for each state. From Silverlight 2 on and the cool new VisualStateManager the task for adding animation and other effects for each state becomes easier. Other than that – we can add animations even for the transitions from one state to another.

     

    In this article I’ll make the same animations like in the previous one but this time using VisualStateManager and styles.

     

    Share
  • 0 comments  /  posted by  Emil Stoychev  on  Jun 01, 2008 (more than a year ago)

    While playing with the ListBox control I want to set the ScrollViewer's VerticalScrollBarVisibility/HorizontalScrollBarVisibility properties in the XAML. The following code illustrates how to do it:

    <ListBox x:Name="StatusList" 
    ScrollViewer.HorizontalScrollBarVisibility="Hidden">
        ...
    </ListBox>
    Share
  • 0 comments  /  aggregated from  Just code - Tamir Khason  on  May 06, 2008 (more than a year ago)   /   original article

    Today, we’ll say “They did not put it there” as lot. And start with DrawingBrush. Yes, there is no Drawing Brush in Silverlight, thus you cannot create neither hatch brush nor pattern brush in Silverlight. But we want it to be there. What to do? To enter into deep reflection

    image

    first thing to do is to look into Reflector.

    Share
  • 1 comments  /  aggregated from  Delay's Blog  on  May 04, 2008 (more than a year ago)   /   original article

    If you've made much use of data binding in WPF or Silverlight, you've probably come across the IValueConverter interface. IValueConverter sits between the data source and destination and gives the developer a chance to examine/alter/replace the data as it flows through the converter. It's been my experience that IValueConverter is a powerful and versatile tool for application developers.

    As part of a recent project, I wanted to display some of an object's properties in a simple list. Specifically, I had an instance and I wanted to display a list of "Property Name: Property Value" entries for each property of that object.

    Share
  • 0 comments  /  aggregated from  Silverlight Brass Tacks  on  May 03, 2008 (more than a year ago)   /   original article

    Source code: http://www.bluerosegames.com/hslcolorsample.zip

    On a recent project (showing up soon on Blue Rose Games) I had the need to create some objects that were identical except for their color. So I created a UserControl for the object, and gave it a property to let me select the color. The problem is, this object uses gradients to get the desired effect, and the color of the gradient stops was a variation of some base color, keeping the color consistent but making it lighter or darker.

    If you've ever done work with color, possibly in Photoshop or something similar, you know that adjusting the lightness of a color using the typical Red, Green, and Blue color components is difficult.

    Share
  • 0 comments  /  aggregated from  Mike Taulty's Blog  on  May 02, 2008 (more than a year ago)   /   original article

    I tried specifying a MaxMessageReceivedSize in my config for a Silverlight WCF proxy today and it didn't seem to be getting picked up. Not sure what's going on there but if it helps anyone at any point then I just ended up doing this in code;

     ImageServiceClient proxy = new ImageServiceClient();
          BasicHttpBinding b = proxy.Endpoint.Binding as BasicHttpBinding;
          b.MaxReceivedMessageSize = 1024 * 1024 * 20;

    and that worked fine for me ( although 20MB is perhaps overkill :-) ).

    Update: I've been advised that the config file isn't read in Silverlight 2 B1 so don't waste too much time typing stuff into it :-)

    Share
  • 0 comments  /  aggregated from  Mike Taulty's Blog  on  Apr 28, 2008 (more than a year ago)   /   original article

    I spent about 2 hours trying to figure this out today so I thought I'd just share it here. Mostly, the time lost comes down to Javascript but that's no big surprise :-(

    Essentially, I'm playing with the HTML Bridge that lets Silverlight .NET code call Javascript code and vice versa. It's all working very smoothly until I want to create an instance of a .NET type ( marked as ScriptableType ) from Javascript.

    I know that somewhere, there's a method that may be called;

    createObject

    createManagedObject

    createManagedInstance

    but I can't figure out what the heck it's called and I can't figure out a decent way of figuring that out :-)

    So...with Silverlight 2 Beta 1 I can confirm that if you have a .NET type such as;

      [ScriptableType]
      public class Point
      {
        [ScriptableMember]
        public int X { get; set; }
        [ScriptableMember]
        public int Y { get; set; }
      }

    and if you've registered this for use from Javascript at some point by calling something like this ( from .NET code );

    HtmlPage.RegisterCreateableType("PointType", typeof(Point));      

    Then you should be able to create one of those from script with something like;

                var plugin = $get("Xaml1");
                plugin.content.services.createObject("PointType");
    

    Note that my plugin ID is "Xaml1" here as generated by Visual Studio.

    Share
  • 1 comments  /  aggregated from  Silverlight Web Services Team  on  Apr 20, 2008 (more than a year ago)   /   original article

    I found a couple of nice databinding tricks with the SyndicationFeed class, while putting together a code sample. The sample has been posted on silverlight.net for some time now (click here and then look for "Syndication - RSS/Atom Feed Reader").

    For those not familiar with it: databinding is the association of an instance of a type or collection with a WPF control. One-way bindings are useful if you update the type or collection programmatically, then the control will reflect the change automatically. Think about an app that gets search results from a web service and adds them to a collection.

    Share
  • 5 comments  /  aggregated from  Laurent Bugnion (GalaSoft)  on  Apr 16, 2008 (more than a year ago)   /   original article

    This article is for Silverlight 2 beta 1

    There is a common misconception that User Controls in Silverlight must be placed in the assembly from which they are referenced. However, this is not true, you can have user controls in an assembly and use them from another assembly. This is not a direct process, however, so let's see how to proceed:

    Preparing the control
    • Create a new Silverlight 2 application in Visual Studio. In this example, we'll name this application "UserControlsPacking".
    Share

Page