【发布时间】:2015-02-27 14:56:32
【问题描述】:
我似乎无法解决这个问题(WPF/c#)。
我有 2 个窗口,父母和孩子。
在父窗口中有一个带有项目的 listviewitem。 在子窗口中有一个文本框可以选择该项目的内容(一个字符串)和“创建”按钮以确认文本框中的字符串进入 listviewitem,然后子窗口关闭。
图片:enter link description here
但是,通常当我单击创建时,文本会被修剪。我无法复制它,甚至不能使用相同的名称,这很奇怪。
图片:enter link description here
我正在使用列表视图,因为它必须看起来与包含许多项目的列表视图完全相同。
这是“创建”按钮的代码。
//Here I put the name into the listview item and into a setting variable for future use.
myparent.lstbcostum.Content = txtname.Text;
Properties.Settings.Default.CostumName = txtname.Text;
//other code for saving other stuff
var savepath = System.AppDomain.CurrentDomain.BaseDirectory + "\\Beats\\Costum";
FileInfo myFile = new FileInfo(savepath + "A.wav");
myFile.Attributes = FileAttributes.Normal;
File.Copy(Globals_Costum.Beata, savepath + "A.wav", true);
myFile = new FileInfo(savepath + "B.wav");
myFile.Attributes = FileAttributes.Normal;
File.Copy(Globals_Costum.Beatb, savepath + "B.wav", true);
//other code for saving other stuff and saving settings
Properties.Settings.Default.CostumFlag = true;
myparent.lstbcostum.IsEnabled = true;
Properties.Settings.Default.Save();
//Closing child this.Close(); WpfApplication1.Window3.Globals_Beat.frmCostumOpened = false;
【问题讨论】:
-
您可以在您的问题中添加一些代码 sn-ps 吗?
-
嗨,我添加了“创建”按钮代码。