DataGridCheckboxColumn two way binding
I got same problem with you ,here is my solution <CheckBox HorizontalAlignment=”Center” IsChecked=”{Binding BoolProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}”/>
I got same problem with you ,here is my solution <CheckBox HorizontalAlignment=”Center” IsChecked=”{Binding BoolProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}”/>
You don’t actually interact directly with the scrollbar, rather you set the FirstDisplayedScrollingRowIndex. So before it reloads, capture that index, once it’s reloaded, reset it to that index. EDIT: Good point in the comment. If you’re using a DataGridView then this will work. If you’re using the old DataGrid then the easiest way to do … Read more
Set the width for the data grid to “Auto”. You’re allowing the columns to resize correctly within the grid itself, but you’ve hard-wired the width to 200. UPDATE: Base on @micas’s comment, I may have misread. If that’s the case, try using 100 for the left column’s width and 100* for the right column (note … Read more
The DataGrid will increase column sizes to fit as the data becomes longer, but it does not automatically decrease column sizes when the length of the data decreases. In your example, you’re right aligning the ‘Change’ column, and using the rest of the space for the ‘Name’ column. Now, when a ‘Change’ property grows large … Read more
PLEASE do not use object as a class name: public class MyObject //better to choose an appropriate name { string id; DateTime date; public string ID { get { return id; } set { id = value; } } public DateTime Date { get { return date; } set { date = value; } } … Read more
In some cases, it might be a bad idea to first add the column to the DataGridView and then hide it. I for example have a class that has an NHibernate proxy for an Image property for company logos. If I accessed that property (e.g. by calling its ToString method to show that in a … Read more
Format the binding by StringFormat: <DataGridTextColumn Header=”Fecha Entrada” Width=”110″ Binding=”{Binding EnterDate, StringFormat={}\{0:dd/MM/yyyy hh:mm\}}” IsReadOnly=”True” /> I think it’s better than writing code behind pieces of code
Well mystery is solved 🙂 My first code above actually works: <Style TargetType=”{x:Type MyControls:ExtendedDataGrid}” BasedOn=”{StaticResource {x:Type DataGrid}}”> <Setter Property=”Template”> … </Setter> </Style> I thought that it is not working becase VS (or Resharper) showed error in my code saying that resource is not found… Bug in VS (or Resharper) 🙁
Same as codekaizen but simpler: <DataGridTextColumn> <DataGridTextColumn.CellStyle> <Style> <Setter Property=”UIElement.IsEnabled” Value=”{Binding IsEditable}” /> </Style> </DataGridTextColumn.CellStyle> </DataGridTextColumn>
Final solution: <Style x:Key=”DataGridContentCellCentering” TargetType=”{x:Type DataGridCell}”> <Setter Property=”Template”> <Setter.Value> <ControlTemplate TargetType=”{x:Type DataGridCell}”> <Grid Background=”{TemplateBinding Background}”> <ContentPresenter VerticalAlignment=”Center” /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>