【发布时间】:2014-09-30 14:00:17
【问题描述】:
编译程序时出现以下错误
"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
提前致谢!
编辑:现在我有一个不同的问题.. 进行这些更改后,我遇到了三个新错误。看看新图像的变化
【问题讨论】:
-
参数个数不对,查看SelectionDisplay文档
-
你有
SelectionDisplay(string, string)和SelectionDisplay(Label,Brush)你打算同时使用它们吗??