Reputation: 23
In my wp8 app, I have check box which is under a listbox.
Here is the XAML code:
<ListBox Name="URLListBox" Grid.Row="2" >
<ListBox.ItemTemplate>
<DataTemplate>
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="400"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="1" Tag="{Binding b1Tag}" Tap="surenameTap" x:Name="surename" FontFamily="Consolas" FontSize="25" Text="{Binding text}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="60,0,0,0"/>
<CheckBox IsEnabled="False" BorderThickness="0" BorderBrush="DarkGreen" Background="DarkGreen" Grid.Column="0" x:Name="checkbox" IsChecked="{Binding file}" ></CheckBox>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I want to update the checkbox while program is working. The checkbox shows if the data is downloaded or not.
I use BackgroundTransferRequest
to download the file. I want the checkbox to be checked when download is finished.
Actually I have class that determines which files are downloaded and I bind it with the checkbox, but it changes the checkbox when I enter the page. That is I should go to previous menu and restart the page that contains checkboxes, then it shows which checkboxes are checked, but I want that when I am in page.
Here is the class that binds the checkbox:
lnk = new linkname();
URLListBox.ItemsSource = lnk.obj();
Upvotes: 1
Views: 204
Reputation: 600
Make sure that you have set the DataContext and Implemented InotifyPropertyChanged Interface, Only when You implement the interface the property will get updated.
And also you have to add Mode="TwoWay" when binding, something like this
IsChecked="{Binding file, Mode="TwoWay"}"
A quick sample is here
Upvotes: 1