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
1700
MVVM : Binding Headers and Lines
posted

Hello,

I need to display an array with a random amount of headers and lines.

I can have 2 to 20 columns and 10 to 200 lines.

So I need to be able to bind a list of headers and lines, all objects are in strings.

I already have another xamDatagrid with custom xaml style, so I would like to re-use it.

Thnaks for your help.

Regards

Parents Reply
  • 16495
    Offline posted in reply to Kevin

    Hello,

     

    Thank you for your post.

     

    I have been looking into it.

     

     In order to be able to bind the Label of XamDataGrid to property in your view model, what I can suggest is to take a look at the following forum thread:

     

     http://es.infragistics.com/community/forums/t/72692.aspx

     

     where similar functionality  was discussed. Basically you can create style for LabelPresenter for each field by using LabelPresenterStyle. You can set property ContentTemplate and create DataTemplate with TextBlock in it. Than you can bind Text property of  TextBlock to element from your IEnumerable collection from your view model. Please let me know if I am missing something about your scenario.

     

    The following code snippet illustrate this scenario:

     

    <Style TargetType="{x:Type igWPF:LabelPresenter}">

                                                <Setter Property="ContentTemplate">

                                                    <Setter.Value>

                                                        <DataTemplate>

                                                            <TextBlock Text="{Binding Source={StaticResource viewModel},Path=Headers[2]}"/>

                                                        </DataTemplate>

                                                    </Setter.Value>

                                                </Setter>

                                            </Style>

     

    Please let me know if you need any further assistance on the matter.

Children