This is a migrated thread and some comments may be shown as answers.

using EditTemplateSelector

1 Answer 18 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 02 Dec 2016, 12:49 PM

Hi to all,

I'm trying to use an EditTemplateSelector, but I have problem to retrieve DataContext of RadWindow, my RadWindow has x:Name="radWindow", its relative ViewModel exposes a List<T> collection called StatiCertificato, it seems that it not found it.

When selector use campoEditTesto it works correctly and it works correclty with campoEditData also, when it uses campoEditStato or campoEditDecisione show me correctly RadComboBox but without items. It checked that my collection are full.

Am I using a wrong approach for binding into ItemSource property? If yes, what's wrong?

<templateSelector:ValoreEditTemplateSelector x:Key="campiEditTemplateSelector">
    <templateSelector:ValoreEditTemplateSelector.campoEditTesto>
        <DataTemplate>
            <TextBox Text="{Binding Valore,Mode=TwoWay}"  />
        </DataTemplate>
    </templateSelector:ValoreEditTemplateSelector.campoEditTesto>
    <templateSelector:ValoreEditTemplateSelector.campoEditStato>
        <DataTemplate>
            <telerik:RadComboBox ItemsSource="{Binding StatiCertificato, ElementName=radWindow}"
                                 SelectedItem="{Binding StatoCertificatoSelezionato,Mode=TwoWay}"
                                 DisplayMemberPath="Descrizione" SelectedValuePath="Valore"/>
        </DataTemplate>
    </templateSelector:ValoreEditTemplateSelector.campoEditStato>
    <templateSelector:ValoreEditTemplateSelector.campoEditDecisione>
        <DataTemplate>
            <telerik:RadComboBox ItemsSource="{Binding DecisioniCertificato, ElementName=radWindow}"
                                 SelectedItem="{Binding DecisioneCertificatoSelezionato,Mode=TwoWay}"
                                 DisplayMemberPath="Descrizione" SelectedValuePath="Valore"/>
        </DataTemplate>
    </templateSelector:ValoreEditTemplateSelector.campoEditDecisione>
    <templateSelector:ValoreEditTemplateSelector.campoEditData>
        <DataTemplate>
            <telerik:RadDatePicker SelectedValue="{Binding Valore, Mode=TwoWay, Converter={StaticResource editDateConverter}}"/>
        </DataTemplate>
    </templateSelector:ValoreEditTemplateSelector.campoEditData>
</templateSelector:ValoreEditTemplateSelector>

1 Answer, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 02 Dec 2016, 06:01 PM
Hello Dario,

Its difficult to determine the underlying cause of the issue without seeing more of your code. Can you put together a small, runnable, sample project that reproduces the issue so that we can debug it directly.

You can make it very simple to reproduce it: just use a single page with your GridView, your RadWindow, the DataTemplates and the TemplateSelectors, and a couple rows of sample data in a stripped down ViewModel.

Note: since you've posted in a forum thread, you won't be able to attach a ZIP file. You can either open a support ticket (you can open a support ticket here) which allows you to attach such files or reply here with a link for us to download the ZIP (e.g. Dropbox).

With this we can help determine why your bindings are not working properly. Thank you for your understanding while we work to resolve your problem.

Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Telerik UI for WPF is ready for Visual Studio 2017 RC! Learn more.
Tags
GridView
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Lance | Manager Technical Support
Telerik team
Share this question
or