Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
xamDataGrid Template field ignored
posted

I am using WPF 15.1 ... and trying to simply increase the margin of one field in my grid, referring to the instructions in the help guide https://www.infragistics.com/help/wpf/17.1/xamdatagrid-configuring-template-field.

Part of my XAML code is:

             <dp:XamDataGrid x:Name="dg1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" AutoFit="true">
               
               <dp:XamDataGrid.FieldLayoutSettings>
                 <dp:FieldLayoutSettings AutoGenerateFields="False"/>
               </dp:XamDataGrid.FieldLayoutSettings>

               <dp:XamDataGrid.FieldLayouts>
                  <dp:FieldLayout>
                     <dp:FieldLayout.Fields>
                        <dp:NumericField Name="#"/>
                        <dp:TextField Name="Account"/>
                        <dp:TextField Name="Instrument"/>
                        <dp:TextField Name="Strategy"/>
                        <dp:TextField Name="Pos"/>

                        <dp:TemplateField Name="Qty">
                          <dp:TemplateField.DisplayTemplate>
                            <DataTemplate>
                              <TextBlock Text="{ig:TemplateEditorValueBinding}"
                                         HorizontalAlignment="Center" Margin="5,0,0,0" Foreground="Blue"/>
                            </DataTemplate>
                          </dp:TemplateField.DisplayTemplate>
                        </dp:TemplateField>
                       
                        <dp:NumericField Name="Entry"/>
                        <dp:NumericField Name="Exit"/>
                        <dp:DateTimeField Name="Entry Time"/>
                        <dp:DateTimeField Name="Exit Time"/>
                        <dp:TextField Name="Entry Name"/>
                        <dp:TextField Name="Exit Name"/>
                        <dp:NumericField Name="Profit"/>
                        <dp:NumericField Name="CNP"/>
                        <dp:NumericField Name="Comm"/>
                        <dp:NumericField Name="Bars"/>
                     </dp:FieldLayout.Fields>
                  
 <!--Mimic NT's (absence of) Record Selector field...-->
                   <dp:FieldLayout.Settings>
                     <dp:FieldLayoutSettings RecordSelectorLocation="None"/>
                   </dp:FieldLayout.Settings>
                 </dp:FieldLayout>

               </dp:XamDataGrid.FieldLayouts>
               
<!--Mimic NT's record selection behaviour-->
               <dp:XamDataGrid.FieldSettings>
                 <dp:FieldSettings CellClickAction="SelectRecord"/>
               </dp:XamDataGrid.FieldSettings>
                                      
           </dp:XamDataGrid>

I have other styles defined that enable me to get negative values displayed in red (eg Profit field)... works fine.

However, the seemingly simple task of just moving the Qty field a little to the right has me stumped... once again.

As you can see, I am attempting to achieve this by setting the margin... maybe there's a better/simpler way, I can't find it.  If there is a simple way to make ALL fields have a small margin... that would be just fine too, but in my case, the Text fields seem to display fine, ie with a small left margin.   Numeric fields don't.

In any case... the above DataTemplate does nothing... no margin, no blue foreground (which I only added to more easily see if ANYTHING of the template was being recognized)... but no dice.  I just get a plain value, jammed right up against the left edge of the column.

Like this... Qty field

but what I would like is the Qty field like this...

Have searched the forums, tried many variations... nothing changes the display of the Qty field.  Which, BTW, I do NOT need to edit... in fact I definitely do NOT want a xamNumericEditor control... just plain old display a number (but nicely ;-))

Any help appreciated.

Parents Reply Children
No Data