(X) Hide this Upcoming webinar on Feb 23rd, 10 am PST (see your local time): Building Line-of-business Applications with Silverlight & WCF Data Services
More webinar info | Register | Other webinars
Tweet @silverlightshow and win a SilverlightShow Tweet-shirt. Learn how >>
Skip Navigation LinksHome / Search

Search

 
Results Per Page

Found 4 results for Ilia Iordanov.
Date between: <not defined> and <not defined>
Search in: News , Articles , Tips , Shows , Showcase , Books

Order by Publish Date   Ascending Title   Rating  

  • 2 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 attached properties. This is needed because either to set or to get value for a specific attached property, you need to use the methods SetValue and GetValue which are defined in the DependencyObject class.
    When you declare an attached property, many advantages from the dependency properties model are coming out of the box for you such as caching, data binding, default values, expressions, styling, property invalidation and more.

    In order to declare a attached property in Silverlight, you have to follow few simple steps as explained in the sample code below.

    C#

    public partial class MySilverlightControl : StackPanel
    {
        //1. Declare the attached property as static, readonly field in your class.
       public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.RegisterAttached(
                  "MyProperty",                                 //Property name
                  typeof( string ),                             //Property type
                  typeof( MySilverlightControl ),               //Type of the dependency property provider
                  new PropertyMetadata( MyPropertyChanged ) )//Callback invoked on property value change
     
        public MySilverlightControl()
        {
            InitializeComponent();
        }
     
        //2. Define the appropriate SetXXX and GetXXX methods, 
        //where XXX should be replaced with the property name
        public static void SetMyProperty( DependencyObject obj, string propertyValue )
        {
            obj.SetValue( MyPropertyProperty, propertyValue );
        }
        public static string GetMyProperty( DependencyObject obj )
        {
            return ( string )obj.GetValue( MyPropertyProperty );
        }
     
        private static void MyPropertyChanged( object sender, DependencyPropertyChangedEventArgs args )
        {
            //Do some processing here when the attached property value has changed...
        }
     
        //Just a sample method illustrating the idea how to obtain the value
        //of the MyProperty property for a specific element.
        private void ProcessTabKey()
        {
            foreach ( UIElement element in this.Children )
            {
                string propertyValue = MySilverlightControl.GetMyProperty( element );
                //Perform some processing according to the my property value.............
            }
        }
    }

    Read more about DependencyObject and DependencyProperty classes on MSDN.
    If you need more information about the attached properties check out this article 'Attached properties in Silverlight'.

    That's it!



  • 4 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.

    In order to declare a dependency property in Silverlight, you have to follow few simple steps as explained in the sample code below.

    C#

    public partial class MySilverlightControl : UserControl
    {
        //1. Declare the dependency property as static, readonly field in your class.
        public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register(
            "MyProperty",                               //Property name
            typeof( string ),                           //Property type
            typeof( MySilverlightControl ),             //Type of the dependency property provider
            new PropertyMetadata( MyPropertyChanged ) );//Callback invoked on property value has changes
     
        public MySilverlightControl()
        {
            InitializeComponent();
        }
     
        //2. Create the property and use the SetValue/GetValue methods of the DependencyObject class
        public string MyProperty
        {
            set
            {
                this.SetValue( MyPropertyProperty, value );
            }
            get
            {
                return ( string )this.GetValue( MyPropertyProperty );
            }
        }
     
        private static void MyPropertyChanged( object sender, DependencyPropertyChangedEventArgs args )
        {
            //Do some processing here...
        }
    }

    Read more about DependencyObject and DependencyProperty classes on MSDN.

    That's it!

  • 0 comments  /  posted by  Ilia Iordanov  on  Sep 08, 2008 (more than a year ago)
    Tags: XAP , Ilia Iordanov

    If you need to create a XAP file you can do it very easily by using Chiron. Chiron is a tool that produces Silverlight application packages (XAPs) for applications using Dynamic Language Runtime (DLR) based languages. The main usage of Chiron is to run as a localhost web-server, and it will automate the XAP file creation with every web-request. Moreover you can manually generate and save XAP file to the disc by running command like:

    > Chiron.exe /directory:MyApp\app /zipdlr:app.xap

    If Chiron is installed it can be found in the following folder 'C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Tools'.

    Read more about Chiron here.

    That's it!

  • 8 comments  /  posted by  Ilia Iordanov  on  Jun 02, 2008 (more than a year ago)
    This article is compatible with the latest version of Silverlight.


    1.       Introduction
    An attached property is a new concept that is defined by Extensible Application Markup Language (XAML). The attached properties are intended to be used as global properties that are settable on any type of object. In WPF/Silverlight, attached properties are typically defined as a form of a dependency property that does not have the conventional property 'wrapper'.
     
    2.       What attached properties are?
    The main ability of the attached properties is to allow different child elements to specify unique values for a property that is actually defined in a parent element...