• WPF 中combox与datagrid绑定


        <Grid x:Name="LayoutRoot"  DataContext="{Binding Source={StaticResource Locator}, Path=CustomerViewModel}">
            <Grid.RowDefinitions>
                <RowDefinition Height="50"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <StackPanel Margin="20,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
                <Label Content="新客户:"/>
                <TextBox TextWrapping="Wrap" Width="142" Margin="0,0,10,0" Name="txt_name" />
                <Label Content="客户类型:"/>
                <ComboBox Width="120" Margin="0,0,20,0" Name="comb_type" ItemsSource="{Binding GetCustomType,Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="Id" />
                <Button Content="添 加" Width="75" Name="bt_add" />
            </StackPanel>
            <DataGrid Margin="0" Grid.Row="1" Name="dg_list" ItemsSource="{Binding GetCustomers}" AutoGenerateColumns="False" IsReadOnly="True"  >
             <DataGrid.Columns>
              <DataGridTextColumn Binding="{Binding Id,Mode=OneWay}" Header="编号" Visibility="Hidden"/>
              <DataGridTextColumn Binding="{Binding Name,Mode=OneWay}" Header="客户名称" Width="100"/>
              <DataGridTextColumn Binding="{Binding CustomType.Name,Mode=OneWay}" Header="客户类型" Width="150"/>
              <DataGridTextColumn Binding="{Binding CreateTime.Date, Mode=OneWay}" Header="创建时间"/>
             </DataGrid.Columns>
            </DataGrid>
        </Grid>
  • 相关阅读:
    定时器应用-最终版
    定时器应用-点击按钮,div向右移动
    通过js读取元素的样式
    延时调用
    定时器应用-切换图片的练习
    BOM对象属性定时器的调用
    BOM浏览器对象模型
    键盘移动
    Python-字符串方法
    Python实现注册和登录
  • 原文地址:https://www.cnblogs.com/swarb/p/9924385.html
Copyright © 2020-2023  润新知