[英]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. 我是Windows Phone的新手,而且已经坚持了好几天。
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. 首先,我尝试使用
ListBox
,通过使用ListBox.ItemContainerStyle
可以轻松地向项目添加边框,但是我发现ListBox
项目在按Tab时会改变颜色,因此我进行了搜索,最后我找到了此答案中所有可用的解决方案,但是接受答案在Windows Phone上不起作用,并且一些答案表示将ListBox
禁用将起作用。因此,我将IsHitTestVisible
设置为false,但这将导致项目中的所有按钮都被禁用。
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. 所以我最后回到
ItemsControl
,它在Windows Phone中没有ItemContainerStyle
属性,但是我在Google上搜索的每个结果都说了这一点。我尝试在模板中设置边框,但根本没有用。
This issue is driving me crazy,any suggestions please! 这个问题使我发疯,请提出任何建议!
Why not define an ItemTemplate? 为什么不定义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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.