【发布时间】:2016-11-09 14:07:35
【问题描述】:
查看
<StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="2">
<RadioButton Content="Verified" IsChecked="{Binding Path=RadioAChecked,Mode=TwoWay}" Foreground="{StaticResource foretwo}"/>
<RadioButton Content="Not Verified" IsChecked="{Binding Path=RadioBChecked,Mode=TwoWay}" Foreground="{StaticResource foretwo}"/>
</StackPanel>
<ListView ItemsSource="{Binding BillList}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Bill_Type}" Style="{StaticResource textblock}"/>
<TextBlock Text="{Binding Bill_Status}" Style="{StaticResource textblock}"/>
<TextBlock Text="{Binding Bill_Date}" Style="{StaticResource textblock}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackPanel>
视图模型
public class BillViewModel : BindableBase
{
IBillDataServices _service;
public BillViewModel(IBillDataServices service)
{
_service = service;
_billList = _service.GetAllBill();
}
private ObservableCollection<BillModel> _billList;
public ObservableCollection<BillModel> BillList
{
get
{
return _billList;
}
set
{
_billList = value;
RaisePropertyChanged("BillList");
}
}
private bool _radioAChecked;
public bool RadioAChecked
{
get { return _radioAChecked; }
set
{
if (_radioAChecked == true)
{
}
}
}
private bool _radioBChecked;
public bool RadioBChecked
{
get { return _radioBChecked; }
set
{
_radioBChecked = true;
if (_radioBChecked == true)
{
}
}
}
我的视图模型 (ViewModel) 中有一个名为 _billList 的集合。该集合包含 Bill_Type、Bill_Status 和 Bill_Date。在这里我需要在列表视图中做一个过滤器。我在集合中有 Bill_Status 的值,例如(“是”和“否”)。如果我检查了第一个单选按钮,那么具有 Bill_Status = "Yes" 的行应该绑定到列表视图。如果选中第二个单选按钮,则 Bill_Status = "No" 行应绑定到列表视图。如何在uwp中这样做?请帮助我。
【问题讨论】: