0

私はこの1時間、これを実験してグーグルで遊んでいましたが、問題を理解できません。基本的に、私はリストボックスを持っており、各アイテムにはテキストブロックとチェックボックスがあります。チェックボックスの横にあるテキストブロックのテキストを緑色に変更する必要があります。以下のコードは私が思いつくことができる最高のものですが、それは機能しません。どんな助けでも大歓迎です。

<DataTemplate x:Key="ListBoxTemplate">
        <Grid
            Width="80">
            <TextBlock
                x:Name="textBlock"
                HorizontalAlignment="Left"
                Text="{Binding Data, Converter={StaticResource DataConverter}}"
                Foreground="#FF859FAF"
                FontSize="12"
                TextWrapping="Wrap"
                Width="50"
                Margin="0"
                Grid.Row="10" />
            <CheckBox
                x:Name="Btn6"
                IsChecked="{Binding IsSelected, Mode=TwoWay}"
                Cursor="Hand"
                Padding="0"
                HorizontalAlignment="Right"
                Height="32"
                VerticalAlignment="Bottom"
                RenderTransformOrigin="0.5,0.5"
                Width="26"
                d:LayoutOverrides="GridBox">
                <i:Interaction.Triggers>
                    <i:EventTrigger
                        EventName="textBlock">
                        <ei:ChangePropertyAction
                            TargetName="textBlock"
                            TargetObject="{Binding ElementName=textBlock}"
                            PropertyName="Width"
                            Value="100">
                        </ei:ChangePropertyAction>
                        <i:InvokeCommandAction
                            Command="{Binding SelectDataCommand, Source={StaticResource ControlViewModel}}"
                            CommandName="SelectDateRangeCommand"
                            CommandParameter="{Binding}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>
            </CheckBox>
4

1 に答える 1

1

(私の悪い英語でごめんなさい)

これはあなたの質問に正確に答えるわけではありませんが、簡単な代替手段は、とバインドIsSelectedして、値がtrueの場合に緑TextBox.Foregroundを返すコンバーターを作成することです。SolidColorBrush

于 2012-05-04T17:40:10.603 に答える