【问题标题】:WPF StringCollection + TextBoxWPF 字符串集合 + 文本框
【发布时间】:2010-09-29 14:55:23
【问题描述】:

ApplicationSetting:RenameSettings - System.Collections.Specialized.StringCollection - 用户 - *文字墙"

<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、Text,以便查看/编辑。遵循我在这里和那里看到的类似模式:

我试过TextBox,TextBlock,Label(只显示单词“(Collection)”)...我怎样才能优雅地绑定它?

【问题讨论】:

    标签: c# wpf binding application-settings


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      • 2011-05-06
      • 2023-03-28
      • 1970-01-01
      • 2011-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多