我添加了 System.Windows 和 Microsoft.LightSwitch.Threading;访问剪贴板。
当我运行这个程序时,我得到这个错误:无效的跨线程访问。
让剪贴板工作的任何想法?
partial void btnCopyFaucets_Execute()
{
// Write your code here.
try
{
string CopyText, nManu, nProductCode, nFaucet;
Faucets cpyfaucet = this.FaucetsSearch.SelectedItem;
nManu = Convert.ToString(cpyfaucet.Manufacturer);
nProductCode = Convert.ToString(cpyfaucet.ProductCode);
nFaucet = Convert.ToString(cpyfaucet.Faucet);
CopyText = nManu + " " + nProductCode + " " + nFaucet;
// THIS IS WHERE THE COMPILER IS NOT HAPPY.
Clipboard.SetText(CopyText);
}
catch (Exception damnit)
{
MessageBox.Show(damnit.Message);
}
}