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

  • SEARCH
  • Home
  • 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 9007771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:46:43+00:00 2026-06-16T01:46:43+00:00

I am trying to enable and disable a Button based on selection in a

  • 0

I am trying to enable and disable a Button based on selection in a ListBox. If a value is selected the button should be enabled.
I am trying to use triggers but it is giving me an error

‘targetname not recognized’.

<UserControl x:Class="Qualification.View.QualificationView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             Height="500" Width="500">
    <Grid>
        <Button Name="btnOpen"  Command="Open" CommandParameter="{Binding ElementName=lstName, Path=SelectedValue}"  Height="23" Width="100" Margin="259,325,141,152">Add Qualification</Button>
        <Grid.CommandBindings x:Uid="key">
            <CommandBinding Command="Open" CanExecute="CommandBinding_CanExecute" Executed="CommandBinding_Executed"/>
        </Grid.CommandBindings>
        <Grid.Resources>
            <Style TargetType="{x:Type TextBox}">
                <Style.Triggers>
                    <Trigger Property="Validation.HasError" Value="true">
                        <Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self},
                               Path=(Validation.Errors)[0].ErrorContent}"/>
                    </Trigger>
                </Style.Triggers>                
            </Style>
            <DataTemplate x:Key="eble">
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent}}" Value="True">
                        <Setter TargetName="btnOpen" Property="IsEnabled" Value="False"/>
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
        </Grid.Resources>
        <Label Height="23" Width="100" Margin="17,35,383,442" RenderTransformOrigin="0.48,-3.217">Search</Label>
        <TextBox Name="txtSearch" Text="{Binding Qm.Search, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}"  Height="23" Width="122" Margin="103,37,0,440" HorizontalAlignment="Left"></TextBox>
        <Button Name="btnGo"  Height="22" Width="30" Margin="205,37,265,441" RenderTransformOrigin="0.633,-1.318" Click="Button_Click_1">Go</Button>
        <ListBox Name="lstName"  ItemsSource="{Binding DocList}"  Width="218" Margin="17,82,265,152">
        </ListBox>
        <!--<Button Command="{Binding AddQual}" CommandParameter="{Binding ElementName=lstName, Path=SelectedValue}"  Height="23" Width="100" Margin="259,325,141,152">Add Qualification</Button>-->
    </Grid>
</UserControl>
  • 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-16T01:46:44+00:00Added an answer on June 16, 2026 at 1:46 am

    You could create a style for your button which handles this.

        <Style x:Key="EnableButtonStyle" TargetType="Button">
            <Style.Triggers>
                <DataTrigger Binding="{Binding Path=SelectedItem, ElementName=yourListBox}" Value="{x:Null}">
                    <Setter Property="IsEnabled" Value="False"></Setter>
                </DataTrigger>
             </Style.Triggers>
        </Style>
    

    Then you bind it to your button:

    <Button Style="{DynamicResource ResourceKey=EnableButtonStyle}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use MultiDataTriggers to enabled/disable a button based on the value of
I'm trying to simply enable/disable a button based on whether a value has been
I'm trying to find a way to use one button to enable/disable commands. (actually,
I'm trying to disable/enable controls based on user permission using a custom security framework
Im am trying to add a check box that will enable/disable the edit button.
I'm trying to enable and disable custom buttons on a jqgrid, but would enable
I am trying to bind enabled property of my button to the maximum value
I am trying to enable/disable grouping dynamically on a jqGrid on a button click,
I'm trying to disable a button when it is clicked: Private Sub submitButton_Click() Me.submitButton.Enabled
I am trying to enable/disable (toggle) GPS programmatically in my app via a button

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.