I have an ItemsControl in a window, one of the columns of which contains a simple very narrow StackPanel, which serves as a Target for a Popup that appears under certain circumstances.
After it has been shown and the user has been informed about something, the user closes this pop-up using a button (the command attached to this button simply sets the property of the view model that Popup.IsOpen is attached to false ).
The popup closes, but its image remains captured on the ItemsControl until it scrolls, or another window does not overlap it.
How to recolor ItemsControl after closing popup ?
the code:
1) ItemsControl
<ScrollViewer ...> <ItemsControl x:Name="ux_List" ItemTemplate="{DynamicResource Lib_ItemTemplate}" ItemsSource="{Binding Path=TemplateInfos,Mode=OneWay}" AlternationCount="2" ... />
2) Element template
<DataTemplate x:Key="Lib_ItemTemplate"> <Grid x:Name="grid"> ... <StackPanel Grid.Column="1"> <Popup IsOpen="{Binding Path=HasError,Mode=OneWay}"> <ContentPresenter Content="{Binding Path=ErrorContext, Mode=OneWay}"
and next to it in the last line of the fragment is a close button.
<Button ... Command="{TemplateBinding CloseButtonCommand}" />
The command is attached to this button, implemented as follows:
private void OnCloseErrorMessageCommand() { HasError = false; ... }
source share