Estoy teniendo un problema a la hora de insertar un UserControl en un formulario. Arrastro mi UserControl al formulario, guardo y me sale la siguiente pantalla:
Busque por SO y hay alguien que tuvo el mismo problema que yo pero no logro entender la respuesta o que decir con ella.
Les muestro brevemente el código y algunas indicaciones para que puedan orientarme en el asunto.
Este es el UserControl y como esta bindeado:
La clase que esta bindeada a bsControl es la siguiente:
namespace SmartInventorySystem.ViewModel.Controls
{
public class DispenseCartControlViewModel : FormViewModel
{
public DispenseCartControlViewModel()
{
ItemsToCheckout = new List<ItemToCheckoutRowViewModel>();
}
public List<ItemToCheckoutRowViewModel> ItemsToCheckout { get; set; }
public decimal SubTotal
{
get; //=> ItemsToCheckout.Sum(x => x.Quantity * x.UnitPrice);
set;
}
public decimal Discount { get; set; }
public decimal Vat { get; set; }
public decimal Total
{
get; //=> SubTotal - Discount + Vat > 0 ? (Vat / 100 * (SubTotal - Discount)) : 0;
set;
}
}
}
Y por ultimo, el codigo que tiene el control:
public partial class DispenseCartControl : UserControl, IDispenseCartView
{
private readonly DispenseCartPresenter _presenter;
public DispenseCartControl()
{
InitializeComponent();
_presenter = new DispenseCartPresenter(this);
State = new DispenseCartControlViewModel();
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public DispenseCartControlViewModel State { get; set; }
public void ShowError(Exception ex)
{
MessageBox.Show(this, ex.Message, "Dispense Cart", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void ShowInfo(string msg)
{
MessageBox.Show(this, msg, "Dispense Cart", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public void UpdateFormBindingSource()
{
bsControl.ResetBindings(false);
}
private void DispenseCartControl_Load(object sender, EventArgs e)
{
bsControl.DataSource = State;
}
}
Actualización 1: Agrego el call-stack de donde me lanza error el designer.
at System.Windows.Forms.BindToObject.CheckBinding() at System.Windows.Forms.BindToObject.SetBindingManagerBase(BindingManagerBase lManager) at System.Windows.Forms.Binding.SetListManager(BindingManagerBase bindingManagerBase) at System.Windows.Forms.ListManagerBindingsCollection.AddCore(Binding dataBinding) at System.Windows.Forms.BindingsCollection.Add(Binding binding) at System.Windows.Forms.BindingContext.UpdateBinding(BindingContext newBindingContext, Binding binding) at System.Windows.Forms.Control.UpdateBindings() at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnParentBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.Control.set_BindingContextInternal(BindingContext value) at System.Windows.Forms.ContainerControl.set_BindingContext(BindingContext value) at System.Windows.Forms.ContainerControl.get_BindingContext() at System.Windows.Forms.Control.get_BindingContextInternal() at System.Windows.Forms.SplitContainer.get_BindingContext() at System.Windows.Forms.Control.get_BindingContextInternal() at System.Windows.Forms.Control.get_BindingContext() at System.Windows.Forms.Control.get_BindingContextInternal() at System.Windows.Forms.ContainerControl.get_BindingContext() at System.Windows.Forms.Control.get_BindingContextInternal() at System.Windows.Forms.ContainerControl.get_BindingContext() at System.Windows.Forms.Control.UpdateBindings() at System.Windows.Forms.Control.OnBindingContextChanged(EventArgs e) at System.Windows.Forms.ContainerControl.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.ControlCollection.Add(Control value) at System.Windows.Forms.Form.ControlCollection.Add(Control value) at System.Windows.Forms.Design.ControlDesigner.DesignerControlCollection.Add(Control c)