DLH*_*DLH 2 wpf caliburn.micro
我在列表视图中显示一个集合,每个列表视图项目都有自己的按钮用于下载相关的 pdf。
我想单击该按钮并在其位置显示一个不确定的进度条。
在我的示例项目中,我只是想在单击项目按钮时反转项目的下载状态。
我的视图模型代码:
private BindableCollection<IDownloadable> _downloadables;
public BindableCollection<IDownloadable> Downloadables
{
get { return _downloadables; }
set
{
_downloadables = value;
NotifyOfPropertyChange(() => Downloadables);
}
}
public void Download(IDownloadable item)
{
item.Downloading = !item.Downloading;
NotifyOfPropertyChange(() => Downloadables);
}
public ShellViewModel()
{
Downloadables = new BindableCollection<IDownloadable>();
Downloadables.Add(new DownloadString("String"));
Downloadables.Add(new DownloadString("String"));
Downloadables.Add(new DownloadString("String"));
}
Run Code Online (Sandbox Code Playgroud)
我的看法:
<ListView Name="Downloadables"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid Background="White">
<ToggleButton Content="{Binding MyString}"
Width="50"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
cal:Message.Attach="Download($dataContext)"/>
<spark:SprocketControl Width="30"
Height="30"
HorizontalAlignment="Center"
VerticalAlignment="Center"
AlphaTicksPercentage="50"
Interval="60"
IsIndeterminate="True"
LowestAlpha="50"
StartAngle="-90"
TickColor="LawnGreen"
TickCount="12"
TickWidth="3"
Visibility="{Binding Downloading, Converter={StaticResource BooleanToVisibilityConverter}}"/>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)
我曾想象 NotifyOfPropertyChanged 会告诉集合项进行更新,但事实似乎并非如此。
| 归档时间: |
|
| 查看次数: |
2313 次 |
| 最近记录: |