WPF 字符串集合 +文本框

发布于 2024-09-26 01:40:20 字数 1233 浏览 5 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蝶舞 2024-10-03 01:40:20

我是个白痴...切换到 ListBox ItemsSource...

    <ListBox Margin="12,129,12,12" Name="textBlock1"  
             ItemsSource="{Binding Source={StaticResource Settings}, Path=Default.RenameSettings, Mode=TwoWay}"/>

I'm an idiot... Switched to ListBox ItemsSource...

    <ListBox Margin="12,129,12,12" Name="textBlock1"  
             ItemsSource="{Binding Source={StaticResource Settings}, Path=Default.RenameSettings, Mode=TwoWay}"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文