I BELIEVE I CAN

加油,努力,奋斗!!

导航

The sixth

     Today I added unit test in our project and talked with customer and the customer looks very happy, the version 2.0 is delivered successfully. The last days we will continue to fixed bugs and added new requirements. We will use bugzilla to surveille our tasks, so I have't much free times to study new technology anon. I will take time off and improve my efficiency.

     New things about style in silverlight.

First we add xml code in App.xaml:

<Application.Resources>
        <Style x:Key="myStyle" TargetType="ContentControl">
            <!--TargetType="Button" or other controls.-->
            <!--'ContentControl' means which controls have content property.-->
            <Setter Property="FontSize" Value="36"></Setter>
            <Setter Property="Margin" Value="50"></Setter>
            <Setter Property="Background"><!-- -->
                <Setter.Value>
                    <LinearGradientBrush><!--gradual change from red to green -->
                        <LinearGradientBrush.GradientStops>
                            <GradientStop Offset="0" Color="Red"/>
                            <GradientStop Offset="1" Color="Green"/>
                        </LinearGradientBrush.GradientStops>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
        </Style>
    </Application.Resources>

And Page.xaml like this:

<Grid x:Name="LayoutRoot" Background="White">
        <Button Content="Click Me" Style="{StaticResource myStyle}" >
            <ToolTipService.ToolTip>
                <ToolTip  Content="Click this button" Style="{StaticResource myStyle}" />
            </ToolTipService.ToolTip>           
        </Button>
    </Grid>

 

Another things I study today is Binding with Conversion

First I Add two classes

 

public class Person
    {
        public Person()
        {
        }

        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }
    }

 

public class People
    {
        public People()
        {
            ThePeople = new List<Person>();
        }
        public List<Person> ThePeople { get; set; }
    }

 

Then we need to add xml codes in Page.xaml:

<UserControl x:Class="SilverlightApplication4.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SilverlightApplication4"  <!--Added local namespace-->
    Width="400" Height="300">
    <UserControl.Resources>
        <local:People x:Key="myList">
            <local:People.ThePeople>
                <local:Person Age="25" FirstName="Zhu" LastName="Fengqin"></local:Person>
                <local:Person Age="24" FirstName="Zhu" LastName="Jerome"></local:Person>
            </local:People.ThePeople>
        </local:People>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <ListBox DataContext="{StaticResource myList}" ItemsSource="{Binding ThePeople}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding FirstName}" Margin="5,0,0,0"/>
                        <TextBlock Text="{Binding LastName}" Margin="5,0,0,0"/>
                        <TextBlock Text="{Binding Age}" Margin="5,0,0,0"/>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </Grid>
</UserControl>

posted on 2008-12-18 16:42  朱小能  阅读(302)  评论(0)    收藏  举报