如何从字符串的开头和结尾删除所有空格?
像这样:
"hello"
返回"hello"
"hello "
返回"hello"
" hello "
返回"hello"
" hello world "
返回"hello world"
我有3 TextBoxes
和1,Button
并希望将每个TextBoxes
数据输入到ListBox
单独的列中.
我知道如何将数据输入一列:
listbox1.Items.Add(TextBox1.text);
Run Code Online (Sandbox Code Playgroud)
但是如何将数据输入多列?
我正在使用.NET WPF.我想用a ListBox
或a ListView
.
如何从C#中的另一个公共类访问一个公共类中的变量?
我有:
public class Variables
{
static string name = "";
}
Run Code Online (Sandbox Code Playgroud)
我需要来自:
public class Main
{
}
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
我正在使用控制台应用程序.
我对绑定不了解。我有一个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 …