This is a migrated thread and some comments may be shown as answers.

Trouble with RadGridView

0 Answers 19 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Joe asked on 06 Nov 2013, 09:00 PM

I have a RadGridView on a user control, which is switched in/out via a ContentControl. The view model behind the grid is a singleton instance, and will be reused.

When the Content property of the ContentControl is changed, a new view is created as it should, however the grid nulls out the SelectedItem property, which then changes the view model underneath when this view/view model goes out of scope. Why does this occur?

I would like to be able to switch this view back in and display the selected item when the user comes back to it, which should be possible, but the grid changes the view model when unbinding.
<UserControl x:Class="InventoryView"
             d:DesignHeight="700" d:DesignWidth="1000">
    <Grid d:DataContext="{d:DesignInstance Type=tools:InventoryViewModel, IsDesignTimeCreatable=True}">
            <ColumnDefinition />
            <ColumnDefinition Width="5"/>
            <ColumnDefinition Width="2*" />
        <TabControl Grid.Column="0">
                <TabItem Header="Networks">
                    <!--<DataGrid ItemsSource="{Binding Networks}" SelectedItem="{Binding SelectedNetwork}"></DataGrid>-->
                        ItemsSource="{Binding Networks}"
                        SelectedItem="{Binding SelectedNetwork}">
                                DataMemberBinding="{Binding Name}"/>
                                DataMemberBinding="{Binding IsPhysical, Converter={StaticResource NetworkTypeConverter} }"/>
                                DataMemberBinding="{Binding ContactName}"/>

<!-- placeholder for main content area view -->
<ContentControl Grid.Row="1"
                Content="{Binding SelectedToolViewModel}"
                ContentTemplateSelector="{Binding Source={StaticResource SelectedToolTemplateSelector}}" />

No answers yet. Maybe you can help?

Asked by
Top achievements
Rank 1
Share this question