小编arc*_*her的帖子

如何从字符串的开头或结尾删除所有空格?

如何从字符串的开头和结尾删除所有空格?

像这样:

"hello"返回"hello"
"hello "返回"hello"
" hello "返回"hello"
" hello world "返回"hello world"

c# string trim removing-whitespace

197
推荐指数
6
解决办法
26万
查看次数

WPF中的多列ListBox

我有3 TextBoxes和1,Button并希望将每个TextBoxes数据输入到ListBox单独的列中.

我知道如何将数据输入一列:

listbox1.Items.Add(TextBox1.text);
Run Code Online (Sandbox Code Playgroud)

但是如何将数据输入多列?

我正在使用.NET WPF.我想用a ListBox或a ListView.

我的窗口

.net wpf listbox multiple-columns

20
推荐指数
3
解决办法
5万
查看次数

从另一个类调用变量

如何从C#中的另一个公共类访问一个公共类中的变量?

我有:

public class Variables
{
   static string name = "";
}
Run Code Online (Sandbox Code Playgroud)

我需要来自:

public class Main
{
}
Run Code Online (Sandbox Code Playgroud)

在此先感谢您的帮助.

我正在使用控制台应用程序.

c# variables static class

15
推荐指数
2
解决办法
18万
查看次数

ListBox ItemsSource WPF绑定

我对绑定不了解。我有一个DataTemplate正在工作的for类型的对象,但在这里我想做一个ListBox并将类型设置为对象属性之一的数据。我一直在使用Snoop来查看数据上下文,ListBox而Object中的数据上下文DataTemplate是Object,但是出现了错误,ItemsSource我不知道为什么。我在做ItemsSource={Binding componentList, Mode=TwoWay}一个对象有一个componentList和componentList是一个ObservableList。我想念什么?

这是我的XAML代码:

<Window.Resources>

<DataTemplate DataType="{x:Type properties:Component}">
  <StackPanel>
    <TextBlock Text="TEST COMPONENT" />
    <ListBox DataContext="{Binding propertyList}" ItemsSource="{Binding propertyList}" />
  </StackPanel>
</DataTemplate>

<DataTemplate DataType="{x:Type properties:Object}">
  <StackPanel>
    <TextBlock Text="TEST OBJECT" />
    <ListBox ItemsSource="{Binding componentList, Mode=TwoWay}" />
  </StackPanel>
</DataTemplate>

</Window.Resources>
Run Code Online (Sandbox Code Playgroud)

和我的C#代码:

public class Component
{
  public string name;
  public ObservableCollection<IProperty> propertyList;
}

public class Object
{
  public UnsignedProperty objectID;
  public ObservableCollection<Component> componentList;
}
Run Code Online (Sandbox Code Playgroud)

ListBox编写了一个in代码并将其设置ItemsSource为Objects列表,并看到了我的Object DataTemplate …

c# wpf binding listbox itemssource

4
推荐指数
1
解决办法
4万
查看次数