I get the following error when I compile the program
\"Microsoft.Samples.Kinect.ControlsBasics.SelectionDisplay\' does not contain a constructor that ta
You should create an overload of SelectionDisplay
's contructor or change the one you already have. Like this:
public SelectionDisplay(string itemId, string tag)
{
//Do something here
}
Due to you're creating a new instance of SelectionDisplay
with two arguments, but its constructor only accept one argument. (string itemId
):
//foreach
new SelectionDisplay(button.Label as string, button.Tag as string); //
//KinectTileButtonClick method
new SelectionDisplay(button.Label, button.Background);
You have to check what type button.Label
, button.Tag
and button.Background
are and create a new constructor with these values.
You can read more about Constructors
here
You have error in two lines:
var selectionDisplay = new SelectionDisplay(button.Label as string, button.Tag as string);
and
var selectionDisplay = new SelectionDisplay(button.Label, button.Background);
and you define the constructor as
public SelectionDisplay(string itemId)
{
this.InitializeComponent();
this.messageTextBlock.Text = string.Format(CultureInfo.CurrentCulture,Properties.Resources.SelectedMessage,itemId);
}
if you need to define with some default value then you need to do like this
public SelectionDisplay(string itemId, string nextParam="default value")
{
this.InitializeComponent();
this.messageTextBlock.Text = string.Format(CultureInfo.CurrentCulture,Properties.Resources.SelectedMessage,itemId);
}
In this case you can either pass next argument or ignore it
Well, you've already created a constructor that takes one argument:
public SelectionDisplay(string itemId)
{
//...
}
But you're passing it two arguments:
new SelectionDisplay(button.Label as string, button.Tag as string);
You can add an argument to the constructor you have, or create a new one:
public SelectionDisplay(string itemId, string someOtherValue)
{
//...
}