我收到以下错误,当我编译程序如何声明构造函数?
“Microsoft.Samples.Kinect.ControlsBasics.SelectionDisplay”不 包含一个构造函数参数2”
我可能需要为我创建的新事物声明另一个构造函数,但我不知道该怎么做。我已经发布了下面的代码,你能帮我吗?
public SelectionDisplay(string itemId)
{
this.InitializeComponent();
this.messageTextBlock.Text = string.Format(CultureInfo.CurrentCulture,Properties.Resources.SelectedMessage,itemId);
}
var files = Directory.GetFiles(@".\GalleryImages");
foreach (var file in files)
{
FileInfo fileInfo = new FileInfo(file);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.UriSource = new Uri(file, UriKind.Relative);
bi.EndInit();
var button = new KinectTileButton
{
Label = System.IO.Path.GetFileNameWithoutExtension(file),
Background = new ImageBrush(bi),
Tag = file
};
var selectionDisplay = new SelectionDisplay(button.Label as string, button.Tag as string);
this.wrapPanel.Children.Add(button);
}
private void KinectTileButtonClick(object sender, RoutedEventArgs e)
{
var button = (KinectTileButton)e.Source;
var image = button.CommandParameter as BitmapImage;
var selectionDisplay = new SelectionDisplay(button.Label, button.Background); // aici poti apoi sa mai trimiti si imaginea ca parametru pentru constructor
this.kinectRegionGrid.Children.Add(selectionDisplay);
e.Handled = true;
}
http://i61.tinypic.com/nno384.png
http://i57.tinypic.com/33vm2k7.png
提前感谢!
编辑:现在我有一个不同的问题..我做了这些更改后,我得到三个新的错误。看看有变化的新形象做出
http://i58.tinypic.com/qwwqvn.png
参数的数目不对,请检查SelectionDisplay文档 –
你'SelectionDisplay(字符串,字符串)'和'SelectionDisplay(标签,刷)'你打算使用他们两个? – Bolu