【发布时间】:2018-02-05 08:49:40
【问题描述】:
我有一个组合框,复选框位于组合框内。我想要多选复选框的值。我的代码:
<ComboBox Name="LocationFilterComboBox" Width="100" SelectedItem="{Binding LocationValue}">
<ComboBox.ItemTemplate >
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<CheckBox Content="{Binding LocationValue}" IsChecked="{Binding ElementName=all, Path=IsChecked, Mode=TwoWay}" Width="120" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
后端代码:
//code to get the value
public partial class Location
{
#region Property
private string LOCAID;
public string LocaId
{
get
{
return LOCAID;
}
set
{
value = LOCAID;
}
}
private string LOCADESC;
public string LocationValue
{
get
{
return LOCADESC;
}
set
{
value = LOCADESC;
}
}
#endregion
}
}
//code for binding the location
public IList<Location> BindAllLocation()
{
if (Repository != null) Repository.Dispose();
Repository = GetInvoiceRepository();
IList<Location> locationList = Repository.GetLocations(((App)Application.Current).DataContextFactory);
return locationList;
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
LocationFilterComboBox.ItemsSource = BindAllLocation();
}
【问题讨论】:
-
我不明白你的问题。您已经在使用绑定。假设您的绑定,您的值应该在属性
IsChecked中;) -
你分享代码示例我如何检索检查项目@MightyBadaboom
-
@AkhilJain 请发布我们可以用作示例的代码。
-
@lightlike 代码已更新
-
@AkhilJain 对不起。我的意思是你绑定到的结构(属性,...)。