Tiberiu
Tiberiu

Reputation: 51

DynamicResource member doesn't update

I have this data template set up for a listbox:

    <DataTemplate x:Key="SlideListItem">
    <StackPanel>
        <Border Margin="1" BorderBrush="#505050" BorderThickness="1">
            <Border.Effect>
                <DropShadowEffect ShadowDepth="1" BlurRadius="3" Opacity=".5" />
            </Border.Effect>
            <Image Source="{Binding Thumbnail}" Stretch="Fill" VerticalAlignment="Center"/>
        </Border>
        <TextBlock Text="{Binding Title}" />
    </StackPanel>
</DataTemplate>

So it is displaying an image, and some text under it. This is the list box:

                <ListBox x:Name="PageList" Grid.Column="0" ItemsSource="{DynamicResource SlideList}" 
                         ItemTemplate="{StaticResource SlideListItem}" MouseDown="PageList_MouseDown" SelectionChanged="PageList_SelectionChanged" />

SlideList is a dynamic resource, more exactly an ObservableCollection of my own class. The class is pretty simple, only has few properties (some strings, an image, and a list)

The problem is that the Thumbnail needs to update every few seconds, but when I try to update it from c#, it doesn't update. The only way I found to make it show the updates is to delete the DynamicResource, and then add it again.

Upvotes: 0

Views: 697

Answers (1)

matthias.lukaszek
matthias.lukaszek

Reputation: 2220

Are you changing the Thumbnail property or are you replacing the item in your ObservableCollection?

In the first case your simple class has to implement INotifyPropertyChanged. Otherwise the binding target will only be updated when changing the collection e.g. replacing an item, adding new items etc., not when changing an item in the collection.

Upvotes: 1

Related Questions