dimanche 1 novembre 2020

WPF CheckBox Content Template with Grid

I was wondering if it's possible to add Grid to CheckBox Content. I bind my content to multiple sources and I need to space it out nicely. For the below, even without binding: TextBlock Text="Some Text" , text won't show up. ListView will only display CheckBox without the Content.

                    <ListView.ItemTemplate>
                        <DataTemplate>

                            <CheckBox IsChecked="{Binding CheckBoxSelected, Mode=TwoWay}"  ToggleButton.Checked="Checked_Click" >
                                <Grid>
                                    <Grid.ColumnDefinitions >
                                        <ColumnDefinition Width="*" />
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="*"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBlock Text="{Binding Building}" Grid.Column="0" Foreground="Black" Cursor="Hand"  HorizontalAlignment="Left"/>
                                    <TextBlock Text="{Binding BLDName, Converter={StaticResource NrConverter}}" Grid.Column="1"   Foreground="Black" Cursor="Hand" HorizontalAlignment="Left" />
                                    <TextBlock Text=" - " Grid.Column="2"   Foreground="Black" Cursor="Hand" HorizontalAlignment="Center"  />
                                    <TextBlock Text="{Binding Structure}" Grid.Column="3"  Foreground="Black" Cursor="Hand" HorizontalAlignment="Right"  />
                                </Grid>
                            </CheckBox>

                           
                        </DataTemplate>
                    </ListView.ItemTemplate>



Aucun commentaire:

Enregistrer un commentaire