locked
Share button doesn't activate Sharing?

    Question

  • I found a sample on the web that demonstrates using the Share contract with a WinRT app.  The button that activated the Share dialog had this for its XAML:

    <Button x:Name="btnShare" Content="Share" Grid.Column="1" HorizontalAlignment="Left" Margin="988,38,0,0" VerticalAlignment="Top" FontSize="18"
                        AutomationProperties.AutomationId="ShareButton" />

    As you can see it does not have an attached event handler or a Command binding.  The only attribute of interest is the AutomationProperties attribute.  When I try a button like this in my app the Share dialog does not activate.  In fact, nothing happens and I don't see any errors in the Output window.

    How can I make the button work in my app?

    Also, can someone link me a good page that talks about the AutomationProperties  feature and how to use it?  I did a search through the Button properties using the string "auto" and found nothing.


    -- roschler

    Wednesday, February 12, 2014 4:17 PM

Answers

  • As you note, that button doesn't do anything on its own. The sample probably hooked up an event handler to it in code.

    The AutomationId gives a conceptually unique ID to the control so it can be found and controlled by accessibility and automation apps. Similar to the x:Name, it doesn't add functionality itself, but it allows identifying the control for external manipulation.

    • Marked as answer by roschler Wednesday, February 12, 2014 7:08 PM
    Wednesday, February 12, 2014 4:22 PM
    Owner

All replies

  • As you note, that button doesn't do anything on its own. The sample probably hooked up an event handler to it in code.

    The AutomationId gives a conceptually unique ID to the control so it can be found and controlled by accessibility and automation apps. Similar to the x:Name, it doesn't add functionality itself, but it allows identifying the control for external manipulation.

    • Marked as answer by roschler Wednesday, February 12, 2014 7:08 PM
    Wednesday, February 12, 2014 4:22 PM
    Owner
  • Thanks Rob.

    -- roschler

    Wednesday, February 12, 2014 7:08 PM