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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:33:50+00:00 2026-06-18T05:33:50+00:00

I finally was able to create an easy transparent button control, based off a

  • 0

I finally was able to create an “easy” transparent button control, based off a ContentControl. However, can someone explain why I couldn’t click/tap any blank areas of the control until I set the background of the child element to transparent? I ran into this issue also when:

  • I tried to use Border
  • I set the ControlTemplate of a button rather than the ContentTemplate.

Here’s my “button” class:

public class TransparentButton : ContentControl {
    public TransparentButton() {            
        HorizontalContentAlignment = HorizontalAlignment.Stretch;
    }

    public override void OnApplyTemplate() {
        var child = Content as Grid;

        if (child != null) {
            child.Background = new SolidColorBrush(Colors.Transparent);
        }

        base.OnApplyTemplate();
    }
}

It’s pretty specific to my cases when using (assuming a Grid child) but it works. The reason I use it is for lists (non-ListBox) with the TiltEffect enabled.

Context of the issue:

<ItemsControl x:Name="Items" toolkit:TiltEffect.IsTiltEnabled="True">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <controls:TransparentButton 
                cal:Message.Attach="[Event Tap] = [Action Go($dataContext)]">
                <Grid>
                    <StackPanel HorizontalAlignment="Left">
                        <TextBlock Text="{Binding Test}" />                            
                    </StackPanel>
                    <StackPanel HorizontalAlignment="Right">
                        <TextBlock Text="{Binding Test2}" />                            
                    </StackPanel>
                </Grid>
            </controls:TransparentButton>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

If you click between the StackPanels inside the item, no event gets fired and nothing happens. Only when the Grid’s Background is Transparent does it “take up space”.

I come from a web background so this is confusing; a containing element should be “hit testable” even when it’s background isn’t set.

  • 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-18T05:33:52+00:00Added an answer on June 18, 2026 at 5:33 am

    An object with no background is usually called as hollow or non-hittable in XAML terms. So it is must to set a background to make the object respond to hits. To achieve hit test for an transparent object, you should set the background to transparent.

    More information about hit testing

    http://msdn.microsoft.com/en-us/library/ms752097.aspx

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

Sidebar

Related Questions

I'm finally able to get an Access Token, now I'm very confused as how
I recently ran across this puzzle, was finally able to struggle out a hacky
Edit2: After finally being able to profile the two against each other, it appears
I've been able to finally get python-openid to authenticate a user, but I'm not
I keep getting null pointer exceptions for methods of MediaPlayer. I was finally able
I have had a lot of success creating graphs with Flot. However, I can
I finally was able to complete the installation of TFS and started the creation
Using the TFS API, I am able to create a TFS item, no problem.
I want to create server which is able to be connected with multiple clients.
I currently create a class which inherits from a Popup . Finally it will

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.