views:

48

answers:

0

Ok, to give a quick rundown of the context of my situation. We have a windows forms tab control, and inside the tab is a element host that contains a wpf usercontrol.

When the tab opens, I have a grid that overlays the whole usercontrol to indicate loading. Below is the xaml. I removed some bindings and xaml that aren't relevant.

<Grid Name="mainGrid">
    <Grid Grid.RowSpan="{Binding ElementName=mainGrid, Path=RowDefinitions.Count}" 
          Grid.ColumnSpan="{Binding ElementName=mainGrid, Path=ColumnDefinitions.Count}">

        <Rectangle Fill="LightGray" />
    </Grid>
</Grid>

Now as you can see, I am binding the rowspan/columnspan to the parent grids row/col count so if I change the rows/columns on the main grid it won't effect the loading indication overlay. If I leave that code in place and open, close, open, close etc... The memory is never reclaimed! Replacing the binding and setting to a hard coded number, the memory will go down when repeating the above process. Am I missing something here or is this a bug in the wpf framework?

---EDIT---

If I add "Mode=OneTime" to the binding it no longer stays in memory. I am still curious though if someone has an answer to why this happens.