c# - 具有多个控件的列表框

标签 c# windows-phone-7 xaml

有人可以帮我创建一个带有复选框和星级评分控件水平对齐的列表框吗?我想要它用于使用 C# 和 XAML 的 WP7。

enter image description here

最佳答案

您需要编写一个自定义列表,这里是一个示例:

您需要包含 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 .

关于c# - 具有多个控件的列表框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10169053/

相关文章:

使用 Slug 的 C# Mvc 通用路由

c# - 是什么阻止了互连的 Winforms 控件之间的无限循环?

windows-phone-7 - 如何录制音频AMR格式?

c# - 将 Windows Phone 麦克风转换为 wma 或 mp3

silverlight - Siliverlight 数据绑定(bind)组合框不显示初始化值

wpf - 从 xaml 模板文件中获取流文档

c# - 如何在 BlockingCollection<T> 实例上进行可中断等待?

c# - 有没有办法在一个 Console.Write(line) 中写入整个 IEnumerable<T>?

c# - LoopingSelector 不显示

xaml - 图像正在 UWP 应用程序中缓存