Click here to Skip to main content
15,887,214 members
Home / Discussions / WPF
   

WPF

 
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 
GeneralRe: Is there any way to automate the silverlight application using Eclipse-testng-selenium-java frameowork Pin
Ashish khanduri20-Nov-16 19:50
Ashish khanduri20-Nov-16 19:50 
QuestionSound Command that can intercept the Active Thread Pin
Vimalsoft(Pty) Ltd15-Nov-16 17:56
professionalVimalsoft(Pty) Ltd15-Nov-16 17:56 
AnswerRe: Sound Command that can intercept the Active Thread Pin
Gerry Schmitz16-Nov-16 6:07
mveGerry Schmitz16-Nov-16 6:07 
QuestionCan't Move Label with mouse in WPF Pin
Dadou5512-Nov-16 22:44
Dadou5512-Nov-16 22:44 
AnswerRe: Can't Move Label with mouse in WPF Pin
Richard Deeming14-Nov-16 2:13
mveRichard Deeming14-Nov-16 2:13 
QuestionHow to achieve grouping and ungrouping usercontrol in wpf application programmatically Pin
Pankaj Deharia10-Nov-16 3:05
professionalPankaj Deharia10-Nov-16 3:05 
AnswerRe: How to achieve grouping and ungrouping usercontrol in wpf application programmatically Pin
Gerry Schmitz10-Nov-16 7:01
mveGerry Schmitz10-Nov-16 7:01 
QuestionHow to solve the echo in a MVVM project with external data updates Pin
ronald6231-Oct-16 0:16
ronald6231-Oct-16 0:16 
AnswerRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz4-Nov-16 5:02
mveGerry Schmitz4-Nov-16 5:02 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
ronald624-Nov-16 5:15
ronald624-Nov-16 5:15 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz4-Nov-16 5:46
mveGerry Schmitz4-Nov-16 5:46 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
ronald627-Nov-16 3:38
ronald627-Nov-16 3:38 
GeneralRe: How to solve the echo in a MVVM project with external data updates Pin
Gerry Schmitz7-Nov-16 6:35
mveGerry Schmitz7-Nov-16 6:35 

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.