我后台查询出来了数据,怎么在前台绑定上,绑定到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> <!--<sdk:Label Name="lable" />--><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();
};
};
显示在一个弹出的页面
前台显示:
<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> <!--<sdk:Label x:Name="lable" />--><br> <ListBox x:Name="listBox" Grid.Row="1" ItemsSource="{Binding Path=Dae, Mode=TwoWay}"><br> <ListBox.ItemTemplate><br> <DataTemplate><br> <StackPanel Orientation="Horizontal"><br> <!--<sdk:Label Name="lable" />--><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);
};
};