WPF List Box

ItemTemplate – DataTemplate

            <ListBox ItemsSource="{Binding}">
                            <StackPanel Orientation="Horizontal">
                                    <Style TargetType="TextBlock">
                                        <Setter Property="Margin" Value="0, 0, 5, 0" />
                                <TextBlock Text="{Binding Path=ID}" />
                                <TextBlock Text="{Binding Path=Task1}" />
                                <TextBlock Text="{Binding Path=PercentComplete}" />
                            <TextBlock Text="Resource names here" Margin="50, 0, 0, 0" />
                            <!--<TextBlock Text="{Binding Path=ResourceName}" Margin="50, 0, 0, 0" />-->



        <CollectionViewSource x:Key="taskViewSource" d:DesignSource="{d:DesignInstance my:Task, CreateList=True}">
                <scm:SortDescription PropertyName="CompleteFlag"
                                     Direction="Descending" />


Style DataTrigger

            <ListBox ItemsSource="{Binding}">
                    <Style TargetType="{x:Type ListBoxItem}">
                            <DataTrigger Binding="{Binding Path=CompleteFlag}"
                                <Setter Property="Background"
                                        Value="Yellow" />

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: