有人可以帮我创建一个带有复选框和星级评级控件水平对齐的列表框吗?我希望它能用于使用C#和XAML的WP7。
答案 0 :(得分:2)
您需要在此处编写自定义列表示例:
您需要包含ControlToolkit:
xmlns:ControlsToolkit="clr-namespace:System.Windows.Controls"
这是代码:
<ListBox x:Name="listBox" SelectionMode="Multiple"
ItemContainerStyle="StaticResource ListBoxCheckedStyle}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Checked="{Binding YourPropertyPath}"/>
<TextBlock Text="{Binding Name}" Width="150" VerticalAlignment="Center"/>
<ControlsToolkit:Rating Height="50" Grid.Row="0" x:Name="rating" ItemCount="5">
<ControlsToolkit:Rating.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</ControlsToolkit:Rating.ItemsPanel>
</ControlsToolkit:Rating>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
您可以从此处下载示例: DownloadSample
或查看详细信息: Sample site
您可以获得有关这些的更多详细信息: CustomDataTemplateSelector WP7 Checked ListBox in different ways
答案 1 :(得分:1)
设置ItemTemplate
:
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Checked="{Binding YourPropertyPath}"/>
<ns:StarControl/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>