views:

22

answers:

1

How can I make such UI:
1) ListBox with items.
2) Detail information about selected item.
3) When you change any item in details information, the selected item in the list becomes bold...
4) ... until you push "Save" button and all changes go to the database.

For example, for Binding to the list I use Object with String Name property and I want to see changes of this property after pushing "Save".

The main trouble is to call force refreshing of the ListBox, when I bind UpdateCommand to the SaveButton Command property.

A: 

You can use a DataTrigger. Add a property to your items view model, named Dirty. Set this to true when you edit an item. When the value of Dirty is true, the datatrigger will set the fontweight to bold.

   <Window.Resources>                
        <Style TargetType="{x:Type TextBlock}" x:Key="AStyle">
            <Style.Triggers>
                <DataTrigger
                    Binding="{Binding Path=Dirty}"
                    Value="True">
                    <Setter Property="FontWeight" Value="Bold" />                    
                </DataTrigger>
            </Style.Triggers>
        </Style>

        <DataTemplate x:Key="ATemplate">
            <StackPanel>
                <TextBlock Text="{Binding Name}" Style="{StaticResource AStyle}" />
            </StackPanel>
        </DataTemplate>
    </Window.Resources>

And then simply set your ItemTemplate to ATemplate

hkon
Thank you, it works. But I still can't make saving only after clicking "Save" button.
JooLio