Shalvin Interests

Tuesday, July 19, 2011

INotifyPropertyChanged Interface

A change-notification handler notifies a binding target that a change has been
made. This enables a target to automatically respond to changes. Dependency properties
already have this feature built in, but CLR properties don’t. If you want your CLR
properties to broadcast their changes, you must implement the INotifyProperty-
Changed interface.

INotifyPropertyChanged interface belongs to System.ComponentModel namespace.

using System.ComponentModel;

namespace INotifyProperyChangeShalvin
{
    public class Speaker : INotifyPropertyChanged
    {
        private string mSpeakerName;
            public string SpeakerName
            {
                get { return mSpeakerName; }
                set
                {
                    mSpeakerName = value;
                    FirePropertyChanged("SpeakerName");
                }
            }
            public event PropertyChangedEventHandler PropertyChanged;


            void FirePropertyChanged(string property)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this,
                        new PropertyChangedEventArgs(property));
                }
            }
        }
    }




private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
    Speaker s = new Speaker { SpeakerName = "Shalvin" };
    LayoutRoot.DataContext = s;
}


<Grid x:Name="LayoutRoot" Background="White">
        <TextBox Height="23" HorizontalAlignment="Left" Margin="120,47,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" Text="{Binding SpeakerName, Mode=TwoWay}" />
        <TextBox Height="23" HorizontalAlignment="Left" Margin="120,147,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" Text="{Binding SpeakerName, Mode=TwoWay}" />
</Grid>

Monday, July 18, 2011

Silverlight Layout Container

Silverlight Layout Containers are panels that derive from the abstract System.Windows.Controls.Panel class. The Properties of Panel class as Background and Children.

The Layout Panels are StackPanel, WrapPanel, DockPanel, Grid and Canvas.

Wednesday, July 13, 2011

Silverlight Styles

Styles is a collection of property value you can apply to an element. In a way it is equivalent to the functionality of CSS in HTML. You store style object as a resource.

<UserControl.Resources>
    <Style x:Key="SimpleStyle" TargetType="Button">
        <Setter Property="Foreground" Value="Blue" />
        <Setter Property="Background" Value="Cyan"/>
    </Style>
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="White">
    <Button Style="{StaticResource SimpleStyle}" Content="Button" Height="23" HorizontalAlignment="Left" Margin="50,76,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="50,137,0,0" Name="button2" VerticalAlignment="Top" Width="75" />
</Grid>

Monday, July 11, 2011

Attached Property

Attached property is a special kind of Dependency Property. Attached propety applies to a class other than one where it is defined.

The best example of Attached property is the Row and Column Properties of Grid class. You set these properties inside the elements in a Grid.

Silverlight Dependency Property

Dependency Property include a mechanism that at any point of time determines what the value of propery should be based on several incluences working on the property such as databinding, styling and so on. These multiple services are called property providers They can be considered as the enabler for animation, databinding, styling and so on.

These different properties are prioritized. Animation is having the highest priority. This prioritization process is called dynamic value resoultion.

The list is as follows :
1. Animation
2. Local value. If you set a value using Resources or data binding it is considered as locally set
3. Styles
4. Property Value Inheritance
5.Default Value

Silverlight FullScreen

private  void btnFullScreen_Click(object sender, RoutedEventArgs e)
{
Application.Current.Host.Content.IsFullScreen = true;
}

Friday, July 8, 2011

UIElement class in Silverlight

UIElement is an object that represents a visual component. These types of elements
A have built-in support for layout, event handling, and rendering.

Silverlight/WPF Object Tree and Visual Tree

The hierarchical tree of objects in XAML file starting from the root going all the way down to elements make up the Object Tree. Object tree contains all types regardless of whether they participate in rending.

Visual Tree is a filtered view of Object Tree containing only those elements with a visual representation.

Thursday, July 7, 2011

User Group Meeting - 9th July 2011 - Kochi

09:30 - 09:40 Community updates
09:40 - 10:40 C# Test Automation by Praseed

10:40 - 11:20 Silverlight - Prism by Mahima
11:20 - 11:40 Tea Break (15 min)
11:40 - 12:30 Sharepoint 2010 programing by Abraham
12.30 - 01:00 Ask the experts


Register