jes9582
jes9582

Reputation: 253

Trigger is not firing

Been doing trial and error on this all day. Thought it might be better to post here and get some feedback on whether I am doing this the right way or not. I am just trying to change the TextBlock ToolTip text when the radio button is checked.

Edit: Figured it out... I applied the Trigger to the DataTemplate instead of the TextBlock itself. (See answer)

Upvotes: 2

Views: 1035

Answers (1)

brunnerh
brunnerh

Reputation: 184516

If you set the text locally the trigger will not be able to change the value due to precedence.

Move the default text into the style:

<!-- There are still issues with this -->
<TextBlock Grid.Row="2" Grid.Column="1">
    <TextBlock.Style>
        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="Text" Value="{Binding SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_REACTOR_Y}"/>
            <Style.Triggers>
                <DataTrigger Binding="{Binding radSimulator, Path=IsChecked}" Value="True">
                    <Setter Property="Text">
                        <Setter.Value>
                            <Binding Path="SIMULATOR_CONTROL_BLADE_DATA.CONTROL_BLADE_ASSEMBLY.REACTOR_CORE_COORDINATE.RCC_MODEL_Y"></Binding>
                        </Setter.Value>
                    </Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
</TextBlock.Style>

This binding is broken:

Binding="{Binding radSimulator, Path=IsChecked}"

This means you set the path twice because the string entered without any property-name will be used as path (see the respective constructor of Binding), should this possibly be this?

Binding="{Binding ElementName=radSimulator, Path=IsChecked}"

Upvotes: 4

Related Questions