vendredi 30 octobre 2015

How to add CheckBox content from resource file in wpf?

I have a combobox in which first item is checkbox to select all entries from below drop down list. With hard coded string its working fine but now I want to localize it...want to set string from resource file but as its deeply inserted couldn't add it. For that I tried adding panel and one checkbox along with textblock also simply separated textblock from checkbox.

This is code :

        <ComboBox Name="CmbEntries" IsTabStop="{Binding CurrentDialogViewModel, Converter={StaticResource NullToBoolConverter}}" Grid.Column="1" Grid.Row="4" VerticalAlignment="Top" Margin="2,0,0,5" SelectedItem="{Binding SelectedEntries}" SelectedIndex="0" HorizontalAlignment="Left" Width="400">
            <ComboBox.Resources>
                <CollectionViewSource x:Key="EntriesCollection" Source="{Binding DicomDir.Entries}"/>
            </ComboBox.Resources>
            <ComboBox.ItemsSource>
                <CompositeCollection>
                    <ComboBoxItem>
                        <CheckBox x:Name="all" Margin="8,0,0,0" 
                                  IsChecked="{Binding IsAllEntriessSelected, Mode=TwoWay}"
                                  Command="{Binding SelectAllEntriessCommand}"
                                  CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}"
                                  **Content="Select All Entries"** />
                    </ComboBoxItem>
                    <CollectionContainer Collection="{Binding Source={StaticResource EntriesCollection}}"/>
                </CompositeCollection>
            </ComboBox.ItemsSource>
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <CheckBox Margin="8,0,0,0" 
                                  IsChecked="{ Binding Path=IsAnyEntitySelected, Mode=TwoWay }"
                                  Command="{Binding SelectAllEntityCommand}"
                                  CommandParameter="{Binding IsChecked, RelativeSource={RelativeSource Self}}" />
                        <TextBlock Margin="5,0,0,0" TextWrapping="Wrap" Text="{Binding DisplayEntriesInfo}"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
            <ComboBox.ItemContainerStyle>
                <Style TargetType="ComboBoxItem">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding HasSelectedEntities}" Value="True">
                            <Setter Property="FontWeight" Value="Bold"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </ComboBox.ItemContainerStyle>
        </ComboBox>

In this case, is it possible to read it directly from resource file?




Aucun commentaire:

Enregistrer un commentaire