qq_34000524 2017-12-04 05:54 采纳率: 0%
浏览 1826

wpf listbox中的checkbox怎么绑定后台查询出来的数据

我后台查询出来了数据,怎么在前台绑定上,绑定到checkbox上,然后根据后台查询的数据个数自动添加checkbox
前台页面显示:

<br> <Setter Property="Background" Value="Transparent"></Setter> <br> <Setter Property="ItemsPanel"><br> <Setter.Value> <br> <ItemsPanelTemplate> <br> <toolkit:WrapPanel Orientation="Horizontal" /> <br> </ItemsPanelTemplate> <br> </Setter.Value> <br> </Setter> <br> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"></Setter><br> <Setter Property="Template"><br> <Setter.Value><br> <ControlTemplate><br> <ListBox x:Name="listBox" Grid.Row="1" ItemsSource="{Binding Path=Dae, Mode=TwoWay}"><br> <ListBox.ItemTemplate><br> <DataTemplate><br> <StackPanel Orientation="Horizontal"><br> &lt;!--<sdk:Label Name="lable" />--&gt;<br> <TextBox Text="{Binding Path=USRCD, Mode=TwoWay}" Background="Transparent" Width="Auto"></TextBox><br> <CheckBox FontSize="14" Content="{Binding Path=USRCD, Mode=TwoWay}" Command="{Binding Path=USRCD, Mode=TwoWay}" IsChecked="{Binding Path=USRCD, Mode=TwoWay}" x:Name="check"></CheckBox><br> </StackPanel><br> </DataTemplate><br> </ListBox.ItemTemplate><br> </ListBox><br> </ControlTemplate><br> </Setter.Value><br> </Setter><br>

            后台页面查询数据:
            public ICommand QueryPersonnel { get { return new DelegateCommand(OnQueryPersonnel); } }
    void OnQueryPersonnel()
    {
            IsBusy = true;
        BusyText = "正在加载 ...";
        _dsm.Load(_dsm.GetTUSRQuery()).Completed += (oo, ee) =>
        {
            LoadOperation<T_USR> loap = (LoadOperation<T_USR>)oo;
                            IsBusy = false;
            if (loap.HasError)
            {
                MessageBox.Show("加载失败!");
                return;
            }
            _Dae = new PagedCollectionView(loap.Entities);
            RaisePropertyChanged(() => Dae);
            PersonDeptManual addInoWin = new PersonDeptManual();
                            addInoWin.Show();
        };
    };


            显示在一个弹出的页面
  • 写回答

1条回答

  • qq_34000524 2017-12-04 05:58
    关注

    前台显示:

    <br> <Setter Property="Background" Value="Transparent"></Setter><br> <Setter Property="ItemsPanel"><br> <Setter.Value><br> <ItemsPanelTemplate><br> <toolkit:WrapPanel Orientation="Horizontal" /><br> </ItemsPanelTemplate><br> </Setter.Value><br> </Setter><br> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"></Setter><br> <Setter Property="Template"><br> <Setter.Value><br> <ControlTemplate><br> &lt;!--<sdk:Label x:Name="lable" />--&gt;<br> <ListBox x:Name="listBox" Grid.Row="1" ItemsSource="{Binding Path=Dae, Mode=TwoWay}"><br> <ListBox.ItemTemplate><br> <DataTemplate><br> <StackPanel Orientation="Horizontal"><br> &lt;!--<sdk:Label Name="lable" />--&gt;<br> <TextBox Text="{Binding Path=USRCD, Mode=TwoWay}" Background="Transparent" Width="Auto"></TextBox><br> <CheckBox FontSize="14" Content="{Binding Path=USRCD, Mode=TwoWay}" Command="{Binding Path=USRCD, Mode=TwoWay}" IsChecked="{Binding Path=USRCD, Mode=TwoWay}" x:Name="check"></CheckBox><br> </StackPanel><br> </DataTemplate><br> </ListBox.ItemTemplate><br> </ListBox><br> </ControlTemplate><br> </Setter.Value><br> </Setter><br>

    后台绑定:
    public ICommand QueryPersonnel { get { return new DelegateCommand(OnQueryPersonnel); } }
    void OnQueryPersonnel()
    {
    IsBusy = true;
    BusyText = "正在加载 ...";
    _dsm.Load(_dsm.GetTUSRQuery()).Completed += (oo, ee) =>
    {
    LoadOperation loap = (LoadOperation)oo;
    IsBusy = false;
    if (loap.HasError)
    {
    MessageBox.Show("加载失败!");
    return;
    }
    _Dae = new PagedCollectionView(loap.Entities);
    RaisePropertyChanged(() => Dae);
    };
    };

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!