Jon
Jon

Reputation: 505

How do I make clickable text

I have been trying to create buttons on Windows Phone 8, which don't look like buttons, but just look like text, however, I haven't been able to find this question answered anywhere else. I am trying to create something like what Microsoft have used below for the camera roll, albums and date buttons below. Is anybody able to explain how I can do this, or maybe link me to a tutorial or something that I may have missed while searching? Thank you.

Example of buttons I am trying to recreate

Upvotes: 2

Views: 1071

Answers (5)

Bugail
Bugail

Reputation: 46

I tend to use a ListBoxItem to wrap a TextBlock. It allows you to use the TiltEffect from the wpToolkit to show interaction and also exposes a Tap event for the ListBoxItem

<ListBoxItem toolkit:TiltEffect.IsTiltEnabled="True" Tap="On_Tap">
    <TextBlock>Hello World</TextBlock>
</ListBoxItem>

Upvotes: 1

VasileF
VasileF

Reputation: 2916

The easiest way is to use HyperlinkButton instead of classic Button. In that print screen I doubt there's a list for only like... 3 buttons (hyperlinkbuttons).

Upvotes: 0

John
John

Reputation: 1764

Controls in the xaml world are look-less: use a button in your ItemTemplate and turn the border off. Then you can use the command property of the button for binding to your VM, or if you are not using MVVM use the Click event of the button and handle it in the code behind.

Upvotes: -1

DotNetRussell
DotNetRussell

Reputation: 9857

Windows phone uses XAML code to create UIElements. Very similar to WPF, you can use almost any UIElement as a button. This is because each element has a large amount of events that can be tracked. Think of it as a layered cake. If you have a textblock inside of a listbox inside of a grid, similar to what you see above. Then when someone clicks on the textblock it will try to handle the event. If it isn't set to handle it then the listbox tries. If the listbox cant then the grid tries and so on. What you are looking for is the tap event in the textblock. Google textblock tap event.

<Grid x:Name="LayoutRoot" Background="Transparent">
    <ListBox>
        <StackPanel>
            <TextBlock Tap="title_Tap_1" Name="title">title</TextBlock>


    private void title_Tap_1(object sender, System.Windows.Input.GestureEventArgs e)
    {
          //Your code here
    }

Upvotes: 2

Emmanouil Chountasis
Emmanouil Chountasis

Reputation: 590

I don't know for Windows Phone 8 because I haven't written any app yet. I think that this is like Windows Phone 7 , 7.1 that I used to write code. This control that you see is a ListBox and inside there are ListBoxItems. ListBoxItem can be anything (it can be used as a container to insert anything inside it.). Hope it helps.

Upvotes: 1

Related Questions