I have a WPF application where i would like to show a progressbar in a datagrid column. Here's what i have so far:
<DataGrid Name="dgOrders" ItemsSource="{Binding}" AutoGenerateColumns="False" HorizontalGridLinesBrush="#35000000" VerticalGridLinesBrush="#35000000" BorderThickness="1" CanUserAddRows="False" CanUserReorderColumns="False" CanUserResizeRows="False" CanUserSortColumns="False" EnableRowVirtualization="False" IsReadOnly="True" RowHeaderWidth="0">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Progress" Width="*" Visibility="Hidden">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ProgressBar Value="{Binding Path=ProgressValue, Mode=OneWay}" Minimum="0" Maximum="100" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
This works and i get nice progressbars on every row. Now here comes the part i get confused: i use this datagrid inside a UserControl what is then used in a Page like this:
<Grid>
<Controls:OrderDataGrid x:Name="cntrlOrderDataGrid"></Controls:OrderDataGrid>
</Grid>
And the pages are loaded from a Frame.
The question is how and where i should implement the class and the ProgressValue so it would update my ProgressBar value binding.
ProgressValue should exists in the ItemsSource that you assign to grid, it is not related if you are using usercontrols and frames or not
Something like this
public class SomeVal : INotifyPropertyChanged
{
public int ProgressValue{...}
}
datagrid.ItemsSource = new [] {new SomeVal()};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With