WPF 字符串集合 +文本框
ApplicationSetting:RenameSettings - System.Collections.Specialized.StringCollection - User - *wall of text"
<Application x:Class="app.App"
...
xmlns:properties="clr-namespace:app.Properties"
StartupUri="MainWindow.xaml">
<Application.Resources>
<properties:Settings x:Key="Settings" />
</Application.Resources>
</Application>
<Window x:Class="app.MainWindow"
...
xmlns:p="clr-namespace:app.Properties"
Height="{Binding Source={StaticResource Settings}, Path=Default.Height, Mode=TwoWay}" MinHeight="300"
...
>
<Window.Resources>
<p:Settings x:Key="settings" />
</Window.Resources>
<Grid DataContext="{StaticResource settings}">
<Menu ... ... />
<Label ... />
<TextBox Margin="12,129,12,12" Name="textBlock1"
Text="{Binding Source={StaticResource Settings}, Path=Default.RenameSettings, Mode=TwoWay}"/>
</Grid>
</Window>
StringCollection...我想将其绑定到文本框、文本,以进行查看/编辑。遵循我在这里看到的类似模式在那里:
我尝试过 TextBox、TextBlock、Label(仅显示单词“(Collection)”)...我怎样才能优雅地绑定它?
ApplicationSetting: RenameSettings - System.Collections.Specialized.StringCollection - User - *wall of text"
<Application x:Class="app.App"
...
xmlns:properties="clr-namespace:app.Properties"
StartupUri="MainWindow.xaml">
<Application.Resources>
<properties:Settings x:Key="Settings" />
</Application.Resources>
</Application>
<Window x:Class="app.MainWindow"
...
xmlns:p="clr-namespace:app.Properties"
Height="{Binding Source={StaticResource Settings}, Path=Default.Height, Mode=TwoWay}" MinHeight="300"
...
>
<Window.Resources>
<p:Settings x:Key="settings" />
</Window.Resources>
<Grid DataContext="{StaticResource settings}">
<Menu ... ... />
<Label ... />
<TextBox Margin="12,129,12,12" Name="textBlock1"
Text="{Binding Source={StaticResource Settings}, Path=Default.RenameSettings, Mode=TwoWay}"/>
</Grid>
</Window>
StringCollection... I'd like to bind it to a TextBox, Text, for viewing/editing. Following a similar patterns I've seen here and there:
I've tried TextBox, TextBlock, Label (only shows the word "(Collection)")... How can I bind this elegantly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我是个白痴...切换到 ListBox ItemsSource...
I'm an idiot... Switched to ListBox ItemsSource...