Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
471
checkbox
posted

Hi all,

 

    <igDP:Field Name="IsSelected" Label="">
                                <igDP:Field.Settings>
                                    <igDP:FieldSettings  CellContentAlignment="LabelAboveValueAlignCenter" LabelMaxWidth="30" AllowEdit="True"  LabelMinWidth="30"  LabelWidth="30"  CellMaxWidth="30" CellMinWidth="30"  CellWidth="30" CellClickAction="EnterEditModeIfAllowed">
                                        <igDP:FieldSettings.CellValuePresenterStyle>
                                            <Style TargetType="{x:Type igDP:CellValuePresenter}">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                                            <CheckBox IsChecked="{Binding Path=DataItem.IsSelected, Mode=TwoWay}" x:Name= "ChkSelected"  Unchecked="ChkSelected_UnChecked" Checked="ChkSelected_Checked" HorizontalAlignment="Center" VerticalAlignment="Center"  Content="" ></CheckBox>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </igDP:FieldSettings.CellValuePresenterStyle>

                                        <igDP:FieldSettings.LabelPresenterStyle   >
                                            <Style TargetType="{x:Type igDP:LabelPresenter}">
                                                <Setter Property="Template">
                                                    <Setter.Value>
                                                        <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}" >
                                                            <StackPanel Orientation="Horizontal" >
                                                                <Label Content=""></Label>
                                                                <CheckBox x:Uid="chkAll" 
                                                                Checked="Chkall_Checked" Visibility="Collapsed"
                                                                  HorizontalAlignment="Center"   
                                                                  VerticalAlignment="Center" ></CheckBox>                               
                                                            </StackPanel>
                                                        </ControlTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </igDP:FieldSettings.LabelPresenterStyle>
                                    </igDP:FieldSettings>
                                </igDP:Field.Settings>
                            </igDP:Field> 

 

I binded  my xam grid  witha datatable  and i want to  check all all the isselected field in my  grid when i clcik the checkbox..

grid bind ::

 

 

 

string strQuery = "select 'false' as IsSelected ,name from table )

i  filled this  query and thro adapter i have filled the datatable

grdApplet.DataSource = dtUserApplets.DefaultView;

in  chkall_checked i have written the code  but it is not  wrking

foreach(datarecord dgin grduser.records)

{

dg.cells[:isselected"].Value=true;

grduser.updatelayout();

 

(it is changing  in grid)

}

 

 

pls can anyone help  how to make  all the values in isselected fiels  as  truewhen i clcick the check  box

 

 

can any one code and give me..

  • 9694
    posted

    Hello,

    I was wondering if the solution offered by another user worked well for you.

    Another alternate solution would be to interate through all the relevant fields in the DataTable itself and modify the field there. Since the XamDataGrid is coupled to the DataTable, the UI would update dynamically.

    Thank you,

  • 5
    Suggested Answer
    posted

    Create a LabelPresenter and associate it with Field where you want checkbox to appear in teh header. And then define an event in code behind for label checkbox. Hope it helps

        <Window.Resources>
            <Style TargetType="{x:Type igDP:LabelPresenter}" x:Key="labelPresenterStyle1">
                <Setter Property="Visibility" Value="Visible" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type igDP:LabelPresenter}">
                            <StackPanel Orientation="Vertical">
                                <TextBlock Text="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Center"/>
                                <CheckBox HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              IsChecked="{Binding Path=DataPresenter.DataContext.Include, Mode=TwoWay}"
                                          Click="cboxHeaderPresenter1_Click"
                                              x:Name="cboxHeaderPresenter1"
                                        />
                            </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>

     

                                <igDP:Field Name="Include" Label="Include">
                                    <igDP:Field.Settings>
                                        <igDP:FieldSettings LabelPresenterStyle="{StaticResource labelPresenterStyle1}"/>
                                    </igDP:Field.Settings>
                                </igDP:Field>

     

            private void cboxHeaderPresenter1_Click(object sender, RoutedEventArgs e)
            {
                bool? val = ((CheckBox)sender).IsChecked;
                foreach (DataRecord dr in grdPopup.Records)
                {
                    dr.Cells["Include"].Value = val;
                }
            }