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
1770
styling subset of dynamic columns using no code behind
posted

I need to style a subset of columns returned by a stored procedure that are dynamic i.e. certain column names will always be returned and have the same name and certain columns will vary based on what parameters were passed to the stored procedure. The style I want to apply is the width as well as change the font size and make the column read only or editable. 

<igWPF:XamDataGrid.FieldLayouts>
<igWPF:FieldLayout>
<igWPF:FieldLayout.Fields>

<!-- THESE ARE STATIC COLUMNS -->

<igWPF:Field Name="valvegroup_log_ID" Visibility="Collapsed" />
<igWPF:Field Name="timeseq" Visibility="Collapsed" />
<igWPF:Field Name="cst" Visibility="Collapsed" />
<igWPF:Field Name="std_datetimeseq" Visibility="Collapsed" />

<igWPF:Field Name="Time" Label="Time" Width="50" />

<!--  HOW DO I APPLY A STYLE TO A SUBSET OF COLUMN WHOS QUANTITY AND NAME WILL VARY BASED ON PARAMETERS

PASSED TO STORED PROC?   -->

</igWPF:FieldLayout.Fields>
</igWPF:FieldLayout>
</igWPF:XamDataGrid.FieldLayouts>

Thanks

Parents
  • 35319
    posted

    Hi Kris,

     

    Thank you for your post. I have been looking into your requirement and the easiest way to achieve it is applying CellValuePresenter style using data triggers. Because the fact that the data triggers do not provide any ‘OR’ statement you will need to declare data trigger for each of the possible fields like e.g.:

     

     <Style TargetType="igDP:CellValuePresenter">

                        <Style.Triggers>

                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Name}" Value="valvegroup_log_ID">

                                <Setter Property="Width" Value="200" />

                                <Setter Property="FontSize" Value="20"/>

                                <Setter Property="IsEnabled" Value="False"/>

                            </DataTrigger>

                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Name}" Value="timeseq">

                                <Setter Property="Width" Value="200" />

                                <Setter Property="FontSize" Value="20"/>

                                <Setter Property="IsEnabled" Value="False"/>

                            </DataTrigger>

                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Name}" Value="cst">

                                <Setter Property="Width" Value="200" />

                                <Setter Property="FontSize" Value="20"/>

                                <Setter Property="IsEnabled" Value="False"/>

                            </DataTrigger>

                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Name}" Value="std_datetimeseq">

                                <Setter Property="Width" Value="200" />

                                <Setter Property="FontSize" Value="20"/>

                                <Setter Property="IsEnabled" Value="False"/>

                            </DataTrigger>

                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Field.Name}" Value="Time">

                                <Setter Property="Width" Value="200" />

                                <Setter Property="FontSize" Value="20"/>

                                <Setter Property="IsEnabled" Value="False"/>

                            </DataTrigger>

                        </Style.Triggers>

                    </Style>

     

    Let me know, if you need any further assistance on this matter.

Reply Children