Click here to Skip to main content
15,916,941 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: UserControl Pin
Kevin Marois5-Dec-16 11:46
professionalKevin Marois5-Dec-16 11:46 
GeneralRe: UserControl Pin
Jon McKee5-Dec-16 11:56
professionalJon McKee5-Dec-16 11:56 
AnswerRe: UserControl Pin
Gerry Schmitz5-Dec-16 11:29
mveGerry Schmitz5-Dec-16 11:29 
GeneralRe: UserControl Pin
Meshack Musundi5-Dec-16 22:23
professionalMeshack Musundi5-Dec-16 22:23 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:49
professionalKevin Marois6-Dec-16 4:49 
GeneralRe: UserControl Pin
Meshack Musundi6-Dec-16 5:04
professionalMeshack Musundi6-Dec-16 5:04 
AnswerRe: UserControl Pin
Richard Deeming6-Dec-16 2:10
mveRichard Deeming6-Dec-16 2:10 
GeneralRe: UserControl Pin
Kevin Marois6-Dec-16 4:47
professionalKevin Marois6-Dec-16 4:47 
QuestionC# WPF listbox binding to selected item does not update my property Pin
Member 128805954-Dec-16 5:54
Member 128805954-Dec-16 5:54 
AnswerRe: C# WPF listbox binding to selected item does not update my property Pin
Richard Deeming5-Dec-16 1:58
mveRichard Deeming5-Dec-16 1:58 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805955-Dec-16 9:08
Member 128805955-Dec-16 9:08 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee5-Dec-16 10:59
professionalJon McKee5-Dec-16 10:59 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805956-Dec-16 7:38
Member 128805956-Dec-16 7:38 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee6-Dec-16 8:23
professionalJon McKee6-Dec-16 8:23 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805956-Dec-16 9:10
Member 128805956-Dec-16 9:10 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee6-Dec-16 10:30
professionalJon McKee6-Dec-16 10:30 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805957-Dec-16 8:10
Member 128805957-Dec-16 8:10 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Jon McKee5-Dec-16 10:13
professionalJon McKee5-Dec-16 10:13 
AnswerRe: C# WPF listbox binding to selected item does not update my property Pin
Gerry Schmitz5-Dec-16 5:51
mveGerry Schmitz5-Dec-16 5:51 
GeneralRe: C# WPF listbox binding to selected item does not update my property Pin
Member 128805955-Dec-16 9:10
Member 128805955-Dec-16 9:10 
QuestionTabControl views are not disposed Pin
Leif Simon Goodwin23-Nov-16 4:55
Leif Simon Goodwin23-Nov-16 4:55 
I have a WPF application which consists of a main window containing a TabControl whose items are populated dynamically from the model. This is a simplified version:

<Window x:Class="WpfDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:view="clr-namespace:WpfDemo.View"
        xmlns:viewmodel="clr-namespace:WpfDemo.ViewModel" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        Title="MainWindow" Height="350" Width="525" Background="#DCE8F3">
    <Grid>
        <TabControl Grid.Row="0" x:Name="ViewTabControl" ItemsSource="{Binding ViewModels}" SelectedItem="{Binding SelectedTab, Mode=TwoWay}" IsSynchronizedWithCurrentItem="True" Background="LightBlue" Margin="6">
            <TabControl.Resources>
                <DataTemplate DataType="{x:Type viewmodel:ImageCaptureViewModel}">
                    <view:ImageCaptureView />
                </DataTemplate>
                <DataTemplate DataType="{x:Type viewmodel:ProfileDesignerViewModel}">
                    <view:ProfileDesignerView/>
                </DataTemplate>
            </TabControl.Resources>
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}"/>
                </DataTemplate>
            </TabControl.ItemTemplate>
        </TabControl>
    </Grid>
</Window>


The view model class - MainWindowViewModel - has an observable collection called ViewModels:

private ObservableCollection<Object> _viewModels;

        public ObservableCollection<Object> ViewModels
        {
            get
            {
                if (_viewModels == null)
                {
                    _viewModels = new ObservableCollection<Object>();
                }
                return _viewModels;
            }
        }


The views are created thus:

public MainWindowViewModel()
        {
            _profileDesignerViewModel = new ViewModel.ProfileDesignerViewModel();
            ViewModels.Add(_profileDesignerViewModel);
            _imageCaptureViewModel = new ViewModel.ImageCaptureViewModel();
            ViewModels.Add(_imageCaptureViewModel);
        }


So far so good. Unfortunately this has a peculiarity. A view is instantiated each time the user selects the corresponding tab. The problem is that the old view is not disposed until the application shuts down.

Does anyone know how to ensure that the old view is disposed, or how to keep the old view and not create a new one? This is creating a serious memory problem for us.
AnswerRe: TabControl views are not disposed Pin
Pete O'Hanlon23-Nov-16 5:30
mvePete O'Hanlon23-Nov-16 5:30 
PraiseRe: TabControl views are not disposed Pin
Leif Simon Goodwin23-Nov-16 21:09
Leif Simon Goodwin23-Nov-16 21:09 
QuestionIs there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Ashish khanduri20-Nov-16 18:23
Ashish khanduri20-Nov-16 18:23 
AnswerRe: Is there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Mycroft Holmes20-Nov-16 19:39
professionalMycroft Holmes20-Nov-16 19:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.