这就是我正在构建的:
每个 ListBoxItem 的右侧应该有 3 个图像,但正如您所看到的,它们只显示在最后一行。我使用的 ContentControl 引用了我从 SyncFusion Metro Studio 获取的 XAML 形状(导出为 XAML)。
我应该使用其他东西吗?
这是我的 XAML:
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition
Height="auto" />
<RowDefinition
Height="auto" />
</Grid.RowDefinitions>
<DockPanel
Grid.Row="0">
<TextBlock
DockPanel.Dock="Left"
Margin="0 0 6 0">
<TextBlock.Text>
<MultiBinding
StringFormat="{}{0:D2}:{1:D2}:">
<Binding
Path="Task.Schedule.StartTime.Hours" />
<Binding
Path="Task.Schedule.StartTime.Minutes" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<ContentControl
Content="{StaticResource CM.Done}"
DockPanel.Dock="Right" />
<ContentControl
Content="{StaticResource CM.Comment}"
DockPanel.Dock="Right" />
<ContentControl
Content="{StaticResource CM.Important}"
DockPanel.Dock="Right" />
<TextBlock
Text="{Binding Task.Name}" />
</DockPanel>
<TextBlock
Grid.Row="1"
Foreground="Gray"
FontStyle="Italic"
Text="{Binding Status, UpdateSourceTrigger=PropertyChanged, Converter={StaticResource StatusEnumToStringConverter}}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
以下是 1 张图像的示例:
<Viewbox
x:Key="CM.Important">
<Grid
Width="24"
Height="24"
Visibility="Visible">
<Path
Data="M2.4915056,2.2260001C3.8691173,2.2260004,4.9830005,3.3431869,4.9830005,4.7181533L4.9830005,52.518807C4.9830005,53.897702 3.8691173,55.010998 2.4915056,55.010998 1.1132736,55.010998 0,53.897702 0,52.518807L0,4.7181533C0,3.3431869,1.1132736,2.2260004,2.4915056,2.2260001z M21.916903,2.1072685E-05C34.563281,-0.013741149 44.850898,6.7199533 60.671,0.96500372 60.671,11.992384 60.671,23.027636 60.671,34.061489 39.577531,41.738621 28.30889,27.205954 8.1920012,36.075898L8.1920012,2.9753833C13.223898,0.75891303,17.701443,0.0046082785,21.916903,2.1072685E-05z"
Stretch="Uniform"
Fill="#FFFF0000"
Width="12"
Height="12"
Margin="0,0,0,0"
RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<TransformGroup.Children>
<RotateTransform
Angle="0" />
<ScaleTransform
ScaleX="1"
ScaleY="1" />
</TransformGroup.Children>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
</Viewbox>