I have an application which loading UserControl Dynamically with code, inside the UserControl I have a RadGrdivView which contains a Checkbox Column, theis is the code i have:
Window:
-----
<Window x:Class="Window2"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window2" Height="300" Width="300" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid>
<telerik:RadTabControl Name="RadTabControl1">
<telerik:RadTabItem Header="Tab1" Name="tb1">
</telerik:RadTabItem>
<telerik:RadTabItem Header="Tab2" Name="tb2">
</telerik:RadTabItem>
</telerik:RadTabControl>
</Grid>
</
Window>
Partial Public Class Window2
Private Sub Window2_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim db As New TeachersDataContext
Dim Te = (From t In db.Teachers Select t).ToList
For Each itm As Telerik.Windows.Controls.RadTabItem In RadTabControl1.Items
Dim uc As New UserControl1
uc.ds = Te
uc.SetDG()
itm.Content = uc
Next
End Sub
End
Class
UserControl:
----
<
UserControl x:Class="UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
<Grid>
<telerik:RadGridView Name="gvTeachers" telerik:StyleManager.Theme="Summer" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" IsReadOnly="True" ShowGroupPanel="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Width="Auto">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<CheckBox Name="chkIs_Selected" Margin="3" IsChecked="True" ></CheckBox>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn HeaderText="Teacher Name" HeaderTextAlignment="Center" Width="*">
<telerik:GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Teacher_Full_Name}"></TextBlock>
</DataTemplate>
</telerik:GridViewColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</
UserControl>
Partial
Public Class UserControl1
Private _ds As List(Of Teacher)
Public Property ds() As List(Of Teacher)
Get
Return _ds
End Get
Set(ByVal value As List(Of Teacher))
_ds = value
End Set
End Property
Public Sub SetDG()
gvTeachers.ItemsSource = _ds
End Sub
End
Class
The problem i have is:
when i run the application all the checkboxes is checked (which is the default state) but when i uncheck some of them and then swich to another tab all the checkboxes is returning to its original state (Checked).
I tried to simulate this issue without loading the UserControls at runtime (I put two RadGridVIews in the TabControl) and everyting is running OK,
Why this happing and if there is any way to solve this please tell me.
Thank you
UserControl
--------------