c# - WPF DataGrid - Align Column with Autogenerated Columns -


I have a WPF Datagrid surrounded by a dataset; Columns are autogenerated I need to align number columns to correct. I can use a converter, like I found on the web in this example:

   & Lt; / Style & gt; & Lt; /DataGridTextColumn.ElementStyle> & Lt; / DataGridTextColumn & gt; & Lt; /DataGrid.Columns> & Lt; / Data grid & gt;   

But in my case the columns are automatically inspired, so I

    

And I do not know how to bind the property

     

any solution?

This can not be an ideal solution

This is what I have tried P> Style

  style target type = "text block" x: key = "column style" & gt; & Lt; Setter Property = "Horizontal Alignment" value = "{Binding Path = Text, Relative Soros = {Relative Asris}, Converter = {Static Resource Alignment Converter}}" /> & Lt; / Style & gt; XAML for DataGrid   
  & lt; DataGrid x: name = "DG" items source = "{binding items}" auto generated column = "True" Autoconnected column = "DG_OnOutO generating columns" selectionMode = "Extended" />   

Event handler code (code behind)

  Zero Dg_OnAutoGeneratedColumns (Object Sender, EventArgs e) {foreach (var Datagreat column dg In column) {var textColumn = DataGridColumnDataGridTextColumn; If (text column == empty) will continue; TextColumn.ElementStyle = FindResource ("Column Style") style; }}   

If you do not like the back codes, you can always create the attached behavior to get the same result.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -