- status: open --> open-fixed
When a Form contains severals user controls, each user control is a View => when user click on a view => automatically this current view (current user control) is activated and the previous view is desactivated.
The problem is the Form is a view too. So each time user click on a user control => activeView is reset to Form.
This behavior creates a situation that user losts focus on the current view.
To fix this, i make new class, derived from WinformsViewsManager, inside this, override 2 following functions and let them empty.
/// <summary>
/// Class without Reset activeView when user change view manually (by click on a view)
/// Suitable for Form having several views, each view is a user control.
/// So when user click on an user control => activeView is always the Form view, not change beetween user controls (as views)
/// </summary>
public class WinformsViewManager_UserControlView : WinformsViewsManager
{
/// <summary>
/// Override this to NOT change view when user activate view manually (by click on a view)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected override void View_ActivatedManually(object sender, EventArgs e)
{
}
protected override void View_Deactivate(object sender, EventArgs e)
{
}
#region Documentation
/// <summary>
/// Returns the default MVCConfiguration instance (obtained via
/// <see cref="MVCConfiguration.GetDefault">MVCConfiguration.GetDefault</see>) with
/// <see cref="MVCConfiguration.ViewInfosProviderType"/> set to
/// <see cref="WinformsViewInfosProvider"/> and
/// <see cref="MVCConfiguration.ViewsManagerType"/> set to <see cref="WinformsViewManager_UserControlView"/>.
/// </summary>
#endregion
public static Pulsar.GUI.MVCSharp.Core.Configuration.MVCConfiguration GetDefaultConfig()
{
MVCConfiguration defaultConf = MVCConfiguration.GetDefault();
defaultConf.ViewsAssembly = System.Reflection.Assembly.GetCallingAssembly();
defaultConf.ViewInfosProviderType = typeof (WinformsViewInfosProvider);
defaultConf.ViewsManagerType = typeof(WinformsViewManager_UserControlView);
return defaultConf;
}
}