2013-09-05 41 views
0

我在我的项目中做了一个列表,每个项目都需要一个按钮。列表框中的按钮

我怎样才能得到列表框中的按钮,就像在我的Windows手机的“最后通话”页面?

谢谢。

回答

0

最简单的方法得到圆形按钮是用户Coding4Fun。它免费使用,安装非常简单。

您可以按照these instructions在您的应用程序中使用它。

至于图标,你可以搜索周围的一些免费包,或者你可以看到如果Metro Studio 2有你需要的图标。该工具也可以免费使用。

1

我们可以像这样为Listbox的每个项目添加按钮。

<ListBox Height="360" 
        HorizontalAlignment="Left" 
        Margin="22,23,0,0" 
        Name="UserDetailsListBox" 
        VerticalAlignment="Top" 
        Width="413"> 
<ListBox.ItemTemplate> 
       <DataTemplate> 
        <StackPanel Orientation="Vertical" 
           > 
    <StackPanel Orientation="Horizontal"> 
         <Button Width="150" Height="50" x:Name="Btn1" Content="Button1"         Margin="0,-20,0,0"/> 
         <TextBlock x:Name="txtOverViewHeader1" 
            Text="OverView" 
            Foreground="Yellow" 
            Width="600" 
            FontSize="28" 
            Margin="10,0,0,0" 
            Height="65"> 
         </TextBlock> 
        </StackPanel> 

      <StackPanel Orientation="Horizontal"> 
         <Button Width="150" Height="50" x:Name="Btn2" Content="Button2"         Margin="0,-20,0,0"/> 
         <TextBlock x:Name="txtOverViewHeader2" 
            Text="OverView" 
            Foreground="Yellow" 
            Width="600" 
            FontSize="28" 
            Margin="10,0,0,0" 
            Height="65"> 
         </TextBlock> 
        </StackPanel> 

       </StackPanel> 
         </DataTemplate> 
        </ListBox.ItemTemplate> 

       </ListBox> 

希望它能给你想要的答案

+0

我正在尝试这样的事情,但我需要那些“圈子”按钮。 – Beetlejuice

0

使用圆形图像,并设置点击事件,或环绕一个按钮模板图像,如果你需要一个按钮特定行为

<ListBox Height="360" 
       HorizontalAlignment="Left" 
       Margin="22,23,0,0" 
       Name="UserDetailsListBox" 
       VerticalAlignment="Top" 
       Width="413"> 
<ListBox.ItemTemplate> 
      <DataTemplate> 
       <StackPanel Orientation="Horizontal"> 
        <Button Template="x:Null" Tap=""> 
         <Image Source="/Assets/Images/MyImage.png" /> 
        </Button> 
        <TextBlock x:Name="txtOverViewHeader1" 
           Text="OverView" 
           Foreground="Yellow" 
           Width="600" 
           FontSize="28" 
           Margin="10,0,0,0" 
           Height="65"> 
        </TextBlock> 
       </StackPanel> 
      </DataTemplate> 
</ListBox.ItemTemplate> 

</ListBox> 
+0

我发现这个网页:http://nirmitk26.blogspot.com.br/2011/02/round-button-in-windows-phone-7.html但它看起来太复杂了。 – Beetlejuice

+0

这是做这个最简单的方法.... –

2

FunksMaName答案是除了一个小的变化非常正确.....

<ListBox Height="360" 
      HorizontalAlignment="Left" 
      Margin="22,23,0,0" 
      Name="UserDetailsListBox" 
      VerticalAlignment="Top" 
      Width="413"> <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel Orientation="Horizontal"> 
       <Button.Template> 
         <ControlTemplate> 
          <Image Source="/Assets/Images/MyImage.png" /> 
         </ControlTemplate> 
        </Button.Template> 
       <TextBlock x:Name="txtOverViewHeader1" 
          Text="OverView" 
          Foreground="Yellow" 
          Width="600" 
          FontSize="28" 
          Margin="10,0,0,0" 
          Height="65"> 
       </TextBlock> 
      </StackPanel> 
     </DataTemplate></ListBox.ItemTemplate></ListBox> 

我只是将按钮的模板内的图像移动而不是内容......这是更准确的..