问题
We have an ItemControl that UserConrols will be added to it, the code is as follows:
<ItemsControl ItemsSource="{Binding CamerasList}" x:Name="AllCamerasControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:SingleView />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Constructor of UserControl is as follows:
public SingleCameraView()
{
InitializeComponent();
DataContext = new SingleViewModel();
}
The problem is that when we open a Remote Desktop Connect to the PC that application is running, the constructor of the usercontrol class gets invoked and after that we got stuck in different problems.
I read this link WPF: Prevent unload & load after RDP (dis)connect , but I can not resolve this issue.
Can anyone help that how can resolve this issue?
来源:https://stackoverflow.com/questions/49715478/wpf-re-invoke-constructor-when-connect-using-remote-desktop-connection-rdp-to