1
我想创建这样一个控制绘制边框:只在我的列表视图中的最后一个项目
控制是指4个对象的状态完成(在上面附着PIC 2完成, 2不是)
为了实现这一点,我创建了一个水平方向的ListView,并且我创建了一个有一些边界的数据模板。不知道这是否是正确的方法,或者是否可以使用更简单的方法我面临的问题如下:
我无法关闭最后一个项目的边框。这是因为我在listview的项目源中有4个项目,每个项目都向左边绘制边框。问题是我如何专门为最后一个项目绘制正确的边框。
穿过中间的线条应该实际上落后于灰色阴影..我怎么实现这一点?
守则如下:
<Style x:Key="FishBoneStyle" TargetType="{x:Type Border}">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=Completed}" Value="True">
<Setter Property="Background" Value="DarkGray"/>
<Setter Property="Margin" Value="0,3,-2,3"/>
</DataTrigger>
</Style.Triggers>
</Style>
<DataTemplate x:Key="FishBoneTemplate">
<Grid Height="25">
<Border BorderThickness="1,0,0,0" BorderBrush="Black" Height="25" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
<Border Style="{StaticResource FishBoneStyle}" x:Name="FishBoneBorder" Width="25">
</Border>
</Grid>
</DataTemplate>
<!-- The Main Grid-->
<Grid Grid.Row="1" Height="30" Width="130" HorizontalAlignment="Left">
<ListView BorderThickness="0,0,0,0" BorderBrush="Black" ItemsSource="{Binding ProgressTiles}" ItemTemplate="{StaticResource FishBoneTemplate}">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
<!-- The line which passess through the center-->
<Border VerticalAlignment="Center" HorizontalAlignment="Left" Width="100" Margin="3,0,2,0" BorderBrush="Black" BorderThickness="1"></Border>
</Grid>
..和这里是躺在我viewmodel.There可观察集合内将始终其中的4个型号。
public class ProgressTile : INotifyPropertyChanged
{
private bool _completed;
public bool Completed
{
get { return _completed; }
set
{
_completed = value;
InvokePropertyChanged("Completed");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void InvokePropertyChanged(string e)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(e));
}
}
请你可以建议如何让图片看起来一致。你也可以请建议如何解决这个问题,为最后一个项目画一个边框,并发送通过中间到背景的线条?