Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:29:04+00:00 2026-06-02T03:29:04+00:00

I have a button control that has its Content property bound to a boolean

  • 0

I have a button control that has its Content property bound to a boolean property on my viewmodel. The button is used to open and close a valve on an industrial machine, performed via an asynchronous WCF call. When the service returns it updates the boolean property which in turn triggers a change to the button’s visual state. This is the button xaml:

<Button Command="{Binding Path=OpenCloseValveCommand}"
        Content="{Binding Path=ValveIsOpen}"
        Style="{StaticResource ResourceKey=OnOffButtonStyle}">

The button needs to be green when the valve is open, and red with a cross through it when the valve is closed. This is the style xaml:

<Style TargetType="Button" x:Key="OnOffButtonStyle" >
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Canvas>
                    <Rectangle x:Name="_rect" Fill="Red" Stroke="Black" Width="30" Height="30"></Rectangle>
                    <Path x:Name="_path" Data="M0,0 L30,30 M0,30 L30,0" StrokeThickness="1" Stroke="Black" />
                </Canvas>
                <ControlTemplate.Triggers>
                    <Trigger Property="Content" Value="true">
                        <Setter TargetName="_rect" Property="Fill" Value="Lime" />
                        <Setter TargetName="_path" Property="Visibility" Value="Hidden" />
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

Unfortunately the trigger doesn’t seem to fire. I’m guessing it’s something to do with the button Content being bound to a boolean type – do I need to use something other than “true” as the trigger value? (The trigger works if I change the viewmodel property to an integer and use 0 or 1, and a trigger Value of “1”).

Thanks in advance

Andy

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:29:06+00:00Added an answer on June 2, 2026 at 3:29 am

    You can specify type explicitly:

    <Window ...
            xmlns:sys="clr-namespace:System;assembly=mscorlib"
            ...>
    
    <Trigger Property="Content">
        <Trigger.Value>
            <sys:Boolean>True</sys:Boolean>
        </Trigger.Value>
        <Setter TargetName="_rect" Property="Fill" Value="Lime" />
        <Setter TargetName="_path" Property="Visibility" Value="Hidden" />
    </Trigger>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Button control that contains an Image object as its content.
I need a button-like control that can have a Checked property, so that when
I have a really basic user control with a button that has an image.
I have a ListBox that each of its items has a button, I set
I have a radio button control adaptor that attempts to render the radio button
I have a custom control that displays a tryAgain button when the control is
I have a user control that contains multiple controls (CheckBox, Button, Label...). I want
I have two array and three button in segment control i want that when
I'm trying to have a button on the self.navigationItem.rightButton that toggles a segmented control
Hi I have a tab control which is bound to a collection property of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.