Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGrid bound to Collection - add UserControls into one Column
    primarykey
    data
    text
    <p>I'm writing a GUI for transmission torrent server. For keeping my torrent info I use an ObservableCollection:</p> <pre><code> public partial class Torrents { private static ObservableCollection&lt;Torrent&gt; _list = new ObservableCollection&lt;Torrent&gt;(); public static ObservableCollection&lt;Torrent&gt; List { get { return _list; } } } </code></pre> <p>For displaying the torrents I use DataGrid which is bound to my ObservableCollection:</p> <pre><code>&lt;DataGrid x:Name="dataGrid" CanUserReorderColumns="True" AutoGenerateColumns="False" ItemsSource="{Binding Source={StaticResource TorrentsClass}, Path=List}" CanUserResizeRows="False" CanUserSortColumns="True" IsReadOnly="True" CellStyle="{StaticResource RightAlignment}"&gt; &lt;DataGrid.Columns&gt; &lt;DataGridTextColumn Header="#" Binding="{Binding Path=Id}" /&gt; &lt;DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" /&gt; &lt;DataGridTextColumn Header="Size" Binding="{Binding Path=Size, Converter={StaticResource SizeConverter}}"/&gt; &lt;DataGridTextColumn Header="Download Speed" Binding="{Binding Path=DownSpeed, Converter={StaticResource SpeedConverter}}"/&gt; &lt;DataGridTextColumn Header="Upload Speed" Binding="{Binding Path=UpSpeed, Converter={StaticResource SpeedConverter}}"/&gt; &lt;DataGridTextColumn Header="Ratio" Binding="{Binding Path=Ratio, StringFormat=F2}"/&gt; &lt;/DataGrid.Columns&gt; &lt;/DataGrid&gt; </code></pre> <p>So far everything works (can't post images yet):</p> <p><img src="https://i.stack.imgur.com/AKlvU.jpg" alt="image"></p> <p>But for displaying torrent status (whether it's paused, downloading, seeding, rechecking and progress on said things) I want to have a progress bar like in uTorrent:</p> <p><img src="https://i.stack.imgur.com/XwWkJ.jpg" alt="image"></p> <p>I've created a custom UserControl with ProgressBar and TextBlock and it works.</p> <p>But how do I add UserControl to Status column? And how to bound data from my ObservableCollection to it? I guess since it will be providing multiple data (progress, enum with torrent state), is it possible to bind it to an object with said properties?</p> <p>Later I will implement context menus in DataGrid to allow pausing selected torrents (don't know how.. yet) and so on, maybe using DataGrid isn't the best idea? What would you suggest if not?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload