Jarvan
Jarvan

Reputation: 1230

Windows phone 8 How to add border to item in itemscontrol

I'm new to Windows Phone and I have stuck in this for days.

What I need is a list with border on each items.

First I try to use ListBox,which easy to add border to item by using ListBox.ItemContainerStyle,but I found items in ListBox will change color while tab on it,so I searching for prevent,at last I found all available solutions in this answer,but the accept answer is not working on Windows Phone, and some answers says make ListBox disabled will be work.So I set IsHitTestVisible to false, but it will cause all buttons in item disabled.

So I came back to ItemsControl at last,it has no ItemContainerStyle property in Windows Phone but every result I googled says that.I tried set border in template but it didn't work at all.

This issue is driving me crazy,any suggestions please!

Upvotes: 0

Views: 327

Answers (1)

Filip
Filip

Reputation: 1864

Why not define an ItemTemplate? You can exactly specify how each item should look. For example:

<ListBox.ItemTemplate>
   <DataTemplate>
      <Border>
       <TextBlock Text="{Binding Title}" FontSize="18" TextWrapping="Wrap" 
             Margin="3 1" /> 
       </Border>                
    </DataTemplate>
 </ListBox.ItemTemplate>

Upvotes: 1

Related Questions