I have found a bug whereby elements inside an Each
that are marked as Deferred
are not removed even if the Observable
is cleared or replaceAll is invoked. If you remove the Deferred
inside the Each
replaceAll and clear work correctly. For the time being I will just not use Deferred
when I need to dynamically update and clear the underlying observable array.
An example project is available : https://drive.google.com/file/d/0Byxe7r1yoUiDT2UxaHJJb3A3aUE/view?usp=sharing
The bug can be replicated on version 0.25 and version 0.26
<StackPanel>
<Each Items="{searchResults}">
<!-- REMOVE THE DEFERRED TO HAVE DESIRED FUNCTIONALITY OF CLEAR AND REPLACEALL -->
<Deferred>
<Grid Columns="auto,1*" Background="#fff">
<Panel>
<Image Width="100" Height="100" StretchMode="UniformToFill" Url="{Icon.URL}" />
</Panel>
<Panel>
<StackPanel Alignment="VerticalCenter" Padding="10,0,0,0">
<Panel>
<Text Value="{Text}" TextWrapping="Wrap" FontSize="13" TextColor="#888" />
</Panel>
</StackPanel>
</Panel>
</Grid>
<Panel Alignment="VerticalCenter">
<Rectangle Height="1" Fill="#dcdee3" />
</Panel>
</Deferred>
</Each>
</StackPanel>
The following methods do not work if the Each
element is wrapped in Deferred
searchResults.clear();
searchResults.replaceAll(newArray);