i got a listbox with items and i use datatemplate to display the items
i want to make a download button, once the user select an item and click the button a progress bar will be added to the selected item datatemplate and will display the download progress, is it possible ?
any pointers will help
<ListBox Name="List" Grid.Row="2"
ScrollViewer.HorizontalScrollBarVisibility="Visible"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
ItemTemplate="{StaticResource ListTemplate}"
ItemsSource="{Binding Path=Items}"
SelectedItem="{Binding Path=SelectedItem}"
ItemContainerStyle="{StaticResource RoundedItem}"
BorderBrush="{x:Null}" BorderThickness="0"
Background="{x:Null}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Margin="10" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
thanks
Yes, it is possible. You can create and
<ItemTemplate>that contains both the “normal” representation of the item as well as the progress bar. Initially you set theVisibilityof the progress bar toCollapsed. When the download starts you change theVisibilitytoVisible(you may also want to collapse other parts of the item).You can databind the
Visibilityproperty to a property of the view-model of the item. You could use a boolean property likeIsDownloadingand then bind through a converter that convertstruetoVisibleandfalsetoCollapsed.To show the progress bar you simply set
IsDownloadingto true and fire thePropertyChangedevent. When download is complete you setIsDownloadingto false and fire thePropertyChangedevent again.Here is a rough sketch on how you can do it. You need a view-model class for your item in the
ListViewthat you can databind to:You also need an
IValueConverterthat can convertBooleantoVisibility:Your view should be based on something like this: