[wp7] ListBox 바인딩 했을 때 안에 CheckBox 체크
<ListBoxx:Name="ReturnTicketListBox" ItemsSource="{BindingItemSource}"Grid.Row="3"ScrollViewer.VerticalScrollBarVisibility="Hidden">
<ListBox.ItemTemplate>
<DataTemplate>
<GridHeight="87"Width="480">
<Grid.ColumnDefinitions>
<ColumnDefinitionWidth="148"/>
<ColumnDefinitionWidth="92"/>
<ColumnDefinitionWidth="80"/>
<ColumnDefinitionWidth="79"/>
</Grid.ColumnDefinitions>
<CheckBoxIsChecked="{BindingIsChecked,Mode=TwoWay}"/>
<StackPanelOrientation="Horizontal" Grid.Column="1">
<TextBlockText="{Bindingh_srcar_no}"HorizontalAlignment="Center"VerticalAlignment="Center"Foreground="Black" />
<TextBlockText="{Bindingh_seat_no}"HorizontalAlignment="Center"VerticalAlignment="Center"Foreground="Black" />
</StackPanel>
<TextBlockText="{Bindingh_ret_amt,Converter={StaticResourceMoneyConveter}}"HorizontalAlignment="Center"Grid.Column="2"VerticalAlignment="Center"Foreground="Black" />
<TextBlockText="{Bindingh_ret_fee,Converter={StaticResourceMoneyConveter}}"HorizontalAlignment="Center"Grid.Column="3"VerticalAlignment="Center"Foreground="Black" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
이렇게 itemsource를 넣고 checkbox를 twoway로 한다
<CheckBox IsChecked="{Binding IsChecked, Mode=TwoWay}"/>
public class ReturnTicketModel
{
public string Test { get; set; }
public bool IsChecked { get; set; }
}
모델은 그냥 이렇게 하면 된다.
너무 쉬운 부분이지만 모르는 사람은 답답할 수도 있고 code behind에서 이벤트 받아서 하는 초보적인 방법으로
할수도 있어서 포스팅 해본다.