Listviewitem修剪内容

时间:2015-02-27 14:56:33

标签: c# wpf listview

我似乎无法解决这个问题(WPF / c#)。

我有2个窗户,父母和孩子。

在父窗口中有一个带有项目的listviewitem。 在子窗口中有一个文本框,用于选择该项目的内容(字符串)和“创建”按钮,以确认文本框中的strng是否在listviewitem中,之后子窗口关闭。

图片:enter link description here

但是,通常当我点击创建文本时会被修剪。我无法重现它,甚至没有使用相同的名称,这很奇怪。

图片:enter link description here

我正在使用listview,因为它必须看起来与附近有很多项目的列表视图完全相同。

以下是“创建”按钮的代码。

//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;

1 个答案:

答案 0 :(得分:0)

在listbox / listview的WPF XAML模板中,您可能有一个文本块。确保将该文本块元素的水平对齐设置为"拉伸",或者,尝试将listbox / listview的horizo​​ntalcontentalignment设置为" Stretch"。它看起来像是在那里有固定的宽度。

起初很困惑,因为从屏幕截图来看,它似乎用感叹号取代了5 ..

相关问题