This is a migrated thread and some comments may be shown as answers.

Telerik Wpf Grid Check Box in Header of the Cell

1 Answer 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shreya Goyal
Top achievements
Rank 1
Shreya Goyal asked on 10 Nov 2009, 12:07 PM
Hi,
      I am facing a problem which i am demonstrating in the following steps:

a) I take a telerik wpf grid like this:

<

 

gridviewcontrols:RadGridView local:RadialPanel.ZIndex="0" Name="grdPendingEncounters" AutoGenerateColumns="False"

 

 

ShowGroupPanel="False"

 

 

CanUserSortColumns="True" ShowColumnFooters="False"

 

 

ColumnsWidthMode="Fill"

 

 

AreRowDetailsFrozen="True" RowDetailsVisibilityMode="VisibleWhenSelected" RowIndicatorVisibility="Collapsed"

 

 

UseAlternateRowStyle="True" Margin="5,1,0,0" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible" Opacity="1">

 

 

 

<gridviewcontrols:RadGridView.Resources>

 

 

 

<local:StatusToColorConverter x:Key="MyConverter" />

 

 

 

</gridviewcontrols:RadGridView.Resources>

 

 

 

<gridviewcontrols:RadGridView.RowAppearance>

 

 

 

<gridviewcontrols:RowAppearanceSettings UseAlternateRowStyle="True" RowStyle="{StaticResource GridViewRowStyle}" AlternateRowStyle="{StaticResource GridViewAlternateRowStyle}" />

 

 

 

</gridviewcontrols:RadGridView.RowAppearance>

 

 

 

<gridviewcontrols:RadGridView.Columns>

 

 

 

<gridviewcontrols:GridViewColumn HeaderCellStyle="{StaticResource FirstHeaderCellStyle}" Width="30" IsFilterable="False">

 

 

 

<gridviewcontrols:GridViewColumn.CellTemplate>

 

 

 

<DataTemplate x:Name="checkBoxDataTemplate">

 

 

 

<CheckBox Name="chkBoxTemplate" Checked="chkBoxTemplate_Checked" Unchecked="chkBoxTemplate_Checked" IsChecked="{Binding isChecked}"></CheckBox>

 

 

 

</DataTemplate>

 

 

 

</gridviewcontrols:GridViewColumn.CellTemplate>

 

 

 

</gridviewcontrols:GridViewColumn>

 

 

 

<gridviewcontrols:GridViewDataColumn Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Date}" HeaderCellStyle="{StaticResource HeaderCellStyle}" DataMemberBinding="{Binding EncounterDate}" IsFilterable="True">

 

 

 

</gridviewcontrols:GridViewDataColumn>

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Patient}" DataMemberBinding="{Binding Patient}" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=ID}" DataMemberBinding="{Binding EncounterID}" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Type}" DataMemberBinding="{Binding EncounterType}" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Provider}" DataMemberBinding="{Binding Provider}" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Location}" DataMemberBinding="{Binding Location}" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=ClaimNo}" DataMemberBinding="{Binding ClaimNo}" IsReadOnly="True" Width="110" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=FinalizedBy}" DataMemberBinding="{Binding FinalizedBy}" Width="130" IsReadOnly="True" IsFilterable="True" />

 

 

 

<gridviewcontrols:GridViewDataColumn HeaderCellStyle="{StaticResource HeaderCellStyle}" Header="{Resx ResxName=PMS.UserInterface.Resources.UIResource, Key=Status}" DataMemberBinding="{Binding Status}" IsReadOnly="True" IsFilterable="True" >

 

 

 

<telerik:GridViewDataColumn.CellStyle>

 

 

 

<Style TargetType="telerik:GridViewCell">

 

 

 

<Setter Property="Foreground" Value="{Binding Status, Converter={StaticResource MyConverter}}" />

 

 

 

</Style>

 

 

 

</telerik:GridViewDataColumn.CellStyle>

 

 

 

</gridviewcontrols:GridViewDataColumn>

 

 

 

</gridviewcontrols:RadGridView.Columns>

 

 

 

</gridviewcontrols:RadGridView>

 


2) Then i set the item source of this grid to null and then to the collection like this:

grdPendingEncounters.ItemsSource =

null;

 

grdPendingEncounters.ItemsSource = GetObservableObjectData(encountersCollection);


3) Then i am adding the Checkbox in the header of the first column like this dynamically

grdPendingEncounters.Columns[0].Header =

null;

 

CheckBox checkBox = null;

checkBox =

new CheckBox();

 

checkBox.Width = (

double)15;

 

checkBox.Checked +=

new RoutedEventHandler(CheckBox_Checked);

 

checkBox.Unchecked +=

new RoutedEventHandler(CheckBox_Checked);

 

 

grdPendingEncounters.Columns[0].Header = checkBox;


4) but it runs successfully in first go and then in second go it is not showing the check box of the first header.

5) and in third go it shows an error like "Specified element is the logical child of another element .Disconnect it first"

Please Help me out.
Thanks in advance
Shreya

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Nov 2009, 04:04 PM
Hello,

Can you post the full stack trace of the exception?

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Shreya Goyal
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or