(X) Hide this Upcoming webinar by Brian Noyes: Querying and Updating Data From Silverlight Clients with WCF RIA Services. February 2nd, 10 am PST (see your local time)
Full webinar info | Register | Read WCF RIA Services Article series by Brian Noyes
Become a member to receive all webinar news by email, or follow all webinar news on Twitter | Facebook | LinkedIn
Skip Navigation LinksHome / Tips

Tips

+
Page 
  • 1
  • 2
  • 3
  • ...
  • 7
Next
Items Resolution

  • 6 comments  /  posted by  Denislav Savkov  on  Aug 29, 2008 (more than a year ago)

    If you want to pass initialize parameters to Silverlight application from an HTML/ASPX page, you have to find the place where your Silverlight control is inserted into the page using ASP.NET 3.5 Silverlight control and insert the InitParameters attribute as shown in the code snippet.

    HTML

    <asp:Silverlight ....
    Share


  • 5 comments  /  posted by  Nikolay Raychev  on  Apr 02, 2009 (more than a year ago)
    Silverlight 3 comes with two built in Pixel Shaders:

    We have the following image:



    We want to blur it:

    <Image Width="300"   
        Source="http://terraristic.net/photos/  
        Brachypelma_albiceps/Brachypelma_albiceps_1.jpg"> 
        <Image.Effect>
            <BlurEffect Radius="8"></BlurEffect>
        </Image.Effect>
    </Image> 

    We have the following result:



    Note the Radius parameter.
    Share
  • 3 comments  /  posted by  Ilia Iordanov  on  Sep 10, 2008 (more than a year ago)

    Probably the first most important thing to mention here is that only inheritors of System.Windows.DependencyObject can be extended with dependency properties. This is needed because either to set or to get value for a specific dependency property, you need to use the methods SetValue and GetValue which are defined in the DependencyObject class.
    When you declare a dependency property, many advantages are coming out of the box for you such as caching, data binding, default values, expressions, styling, property invalidation and more.

    Share
  • 4 comments  /  posted by  Nikolay Raychev  on  Apr 02, 2009 (more than a year ago)
    In Silverlight 3 you can make multiple selections in a ListBox. You just need to set the SelectionMode parameter:

    <ListBox Margin="5" x:Name="lbTasks"   
        ItemsSource="{Binding Tasks, ElementName=MainPageView}"   
        SelectionMode="Multiple">  
        <ListBox.ItemTemplate> 
            <DataTemplate> 
                <StackPanel Orientation="Horizontal" Margin="2">  
                    <TextBlock FontWeight="Bold" FontSize="13"   
                        Foreground="#ff006882" Text="{Binding Text}">  
                    </TextBlock> 
                </StackPanel> 
            </DataTemplate> 
        </ListBox.ItemTemplate> 
    </ListBox> 

    You have 3 options for the SelectionMode:
    • Single - you can select only one item.
    Share
  • 8 comments  /  posted by  Denislav Savkov  on  Aug 29, 2008 (more than a year ago)

    INotifyPropertyChanged interface is used to notify that a property has been changed and thus to force the bound objects to take the new value.

    C#

    public class Client : INotifyPropertyChanged
    {
        private string name;
        public event PropertyChangedEventHandler PropertyChanged;
     
        public string Name
        {
            get
            {
                return this.Name;
            }
            set
            {
                if ( this.name == value )
                    return;
     
                this.name = value;
                this.OnPropertyChanged( new PropertyChangedEventArgs( "Name" ) );
            }
        }
     
        protected virtual void OnPropertyChanged( PropertyChangedEventArgs e )
        {
            if ( this.PropertyChanged != null )
                this.PropertyChanged( this, e );
        }
    }

    Note that the value is changed only if the new value is different.

    Share
  • 6 comments  /  posted by  Martin Mihaylov  on  Sep 09, 2008 (more than a year ago)

    If you're not familiar with the value converters read this. The methods generated by the VisualStudio when creating a custom class that implements System.Windows.Data.IValueConverter have several arguments. One of them is of type object and is called parameter.

     

    public class DateTimeConverter : System.Windows.Data.IValueConverter
    {
        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )...
       
        public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )...
    }

     

    In this example we bind to an object of type Book:

    public class Book
    {
        public DateTime PublishDate { get; set; }
    }

    We can pass this argument from the code or from the Xaml.

    Share
  • 11 comments  /  posted by  Emil Stoychev  on  Mar 23, 2009 (more than a year ago)

    Like in CSS you can now cascade styles in Silverlight 3 too. You can append and/or override values by basing one style on another. In this way you can built a powerful and reusable set of styles to apply in your Silverlight applications.

    Syntax

    Style cascading is accomplished by using the new BasedOn attribute of the Style class.

       1: <Style x:Name="Headline" TargetType="TextBlock">
       2:     <Setter Property="FontFamily" Value="Verdana" />
       3:     <Setter Property="FontSize" Value="14" />
       4: </Style>
       5: <Style x:Name="ImportantHeadline" TargetType="TextBlock" 
       6:     BasedOn="{StaticResource Headline}">
       7:     <Setter Property="Foreground" Value="Red" />
       8: </Style>        
       9: <Style x:Name="HomePageHeadline" TargetType="TextBlock" 
      10:     BasedOn="{StaticResource Headline}">
      11:     <Setter Property="FontSize" Value="18" />
      12: </Style>

    Here we have a base style Headline that targets TextBlock elements and defines values for FontFamily and FontSize.

    Share
  • 9 comments  /  posted by  Martin Mihaylov  on  Sep 07, 2008 (more than a year ago)

    Here is an example of how to use a LinearGradient Brush to fill a rectangle for example:

    Xaml

    <Rectangle x:Name="MyRect" Width="100" Height="100">
        <Rectangle.Fill>
            <LinearGradientBrush StartPoint="0,0" EndPoint="1,1" >
                <GradientStop Color="Yellow" Offset="0.2"></GradientStop>
                <GradientStop Color="Orange" Offset="0.5"></GradientStop>
                <GradientStop Color="Red" Offset="0.8"></GradientStop>
            </LinearGradientBrush>
        </Rectangle.Fill>
    </Rectangle>

    C# 

    LinearGradientBrush gradient = new LinearGradientBrush();
    gradient.StartPoint = new Point( 0, 0 );
    gradient.EndPoint = new Point( 1, 1 );
     
    GradientStop color1 = new GradientStop();
    color1.Color = Colors.Yellow;
    color1.Offset = 0.2;
    gradient.GradientStops.Add( color1 );
     
    GradientStop color2 = new GradientStop();
    color2.Color = Colors.Orange;
    color2.Offset = 0.5;
    gradient.GradientStops.Add( color2 );
     
    GradientStop color3 = new GradientStop();
    color3.Color = Colors.Red;
    color3.Offset = 0.8;
    gradient.GradientStops.Add( color3 );
     
    MyRect.Fill = gradient;

    We define the gradient and set its StartPoint and EndPoint properties.

    Share
  • 10 comments  /  posted by  sam  on  Mar 24, 2010 (10 months ago)

     Sample RSS Feed application using Windows Phone 7 Series SDK.

    Shows RSS feed title list from http://www.visitmix.com/RSS 

    Article details showed in WebBrowser control based on user selection in the list.

     RSS app code 

    Share
  • 0 comments  /  posted by  Denislav Savkov  on  Sep 01, 2008 (more than a year ago)

    User control static resources are used to declare instances of objects that should be alive and reusable throughout the whole life of a user control. When you declare a static resource in the Xaml of a user control Visual Studio actually declares this instance as an internal class field of that user control, thus making it directly accessible only in your code behind. Usually such things like styles and templates are declared as static resources and as result they can be used multiple times from within your control.

    Share

Page 
  • 1
  • 2
  • 3
  • ...
  • 7
Next