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 5950911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:27:41+00:00 2026-05-22T17:27:41+00:00

I have made a custom control in wpf however I am having an issue

  • 0

I have made a custom control in wpf however I am having an issue with the button that forms a part of the item control (the x in each item element in the attached picture is the button) basically the button is disabled, but I am not disabling it!

If I just place one of the inner items (MultiSelectionItem) into a grid by itself then the button works fine, so it must have something to do with my usage of the ItemsControl element in the Template for the outer control (MultiSelectionBox)

Image:

img

<Style TargetType="{x:Type local:MultipleSelectionBox}">
 <Setter Property="Template">
  <Setter.Value>
    <ControlTemplate TargetType="{x:Type local:MultipleSelectionBox}">
      <Border Background="{TemplateBinding Background}"
              BorderBrush="{TemplateBinding BorderBrush}"
              BorderThickness="{TemplateBinding BorderThickness}">
        <ItemsControl ItemsSource="{Binding multipleSelectionItems}">
          <ItemsControl.Template>
            <ControlTemplate>
              <WrapPanel IsItemsHost="True"/>
            </ControlTemplate>
          </ItemsControl.Template>
        </ItemsControl>
      </Border>
    </ControlTemplate>
  </Setter.Value>
 </Setter>
</Style>

 <Style TargetType="{x:Type local:MultipleSelectionItem}">
<Setter Property="Template">
  <Setter.Value>
    <ControlTemplate TargetType="{x:Type local:MultipleSelectionItem}">
      <Border BorderBrush="#FFC0CBD9" BorderThickness="1" Margin="0,0,2,2" CornerRadius="0">
        <Border.Style>
          <Style TargetType="Border">
            <Style.Triggers>
              <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background">
                  <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                      <GradientStop Color="#FFDFE9F5" Offset="0" />
                      <GradientStop Color="#FFEEF3FC" Offset="1" />
                    </LinearGradientBrush>
                  </Setter.Value>
                </Setter>
              </Trigger>
            </Style.Triggers>
          </Style>
        </Border.Style>
        <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="20" />
            <ColumnDefinition Width="*" />
          </Grid.ColumnDefinitions>
          <Button Command="{x:Static local:MultipleSelectionItemCommands.RemoveCommand}" IsEnabled="True">
            <Button.Template>
              <ControlTemplate>
                <Image Source="/CustomFormResearch;component/Images/x_no_hover.jpg" Margin="2,0,0,0" Height="11" Width="11">
                  <Image.Style>
                    <Style TargetType="{x:Type Image}">
                      <Setter Property="Source" Value="/CustomFormResearch;component/Images/x_no_hover.jpg" />
                      <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                          <Setter Property="Source" Value="/CustomFormResearch;component/Images/x_with_hover.jpg" />
                        </Trigger>
                      </Style.Triggers>
                    </Style>
                  </Image.Style>
                </Image>
              </ControlTemplate>
            </Button.Template>
          </Button>
          <TextBlock Text="{Binding DisplayData}" VerticalAlignment="Stretch" Margin="5,0,5,0" Grid.Column="1" />
        </Grid>
      </Border>
    </ControlTemplate>
  </Setter.Value>
</Setter>
</Style>
  • 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-05-22T17:27:42+00:00Added an answer on May 22, 2026 at 5:27 pm

    My first guess is that since your button is bound to a Command, the CanExecute of the command should return false.

    This is the principle and benefit of a Command: When the can execute returns false it automaticaly disable the associated button.

    Check this links for more about commands and MVVM :

    http://msdn.microsoft.com/en-us/magazine/dd419663.aspx

    http://msdn.microsoft.com/fr-fr/magazine/cc785480.aspx#id0190094

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom WPF control that I made a couple of days ago:
I have a custom control that I made. It inherits from System.Windows.Forms.Control , and
I have a custom control that is made up of a text field and
I'm writing php and I have a custom made control that is Grid and
I have a custom-made view that extends the View class. I would like 2
I made a custom handler that derives from MvcHandler. I have my routes using
I have made a custom control in my application. It is like a combo
So I have made a custom required field validator that turns the background of
I have made some custom attached properties that enable me to create a pop
I've made a custom control that inherits from a Literal control. When I try

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.