-1

I have following code in xaml:

                    <DataGridTemplateColumn Header="Status" Width="120">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel>
                                <ComboBox x:Name="_status" ItemsSource="{Binding status}" />
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

Can someone explain me why i can't access _status ComboBox? I'm trying to assign it to:

_status.ItemsSource = statuses.jobStatus();
arti
  • 645
  • 1
  • 8
  • 27
  • `_status` can just be accessed inside the CellTemplate, the current context in codebehind is out of that scope. Please use some pattern here, use Binding instead of setting the ItemsSource like that. – King King Nov 11 '14 at 20:26
  • how can i bind it to method in another class then? Not experienced with xaml that much – arti Nov 12 '14 at 12:50

2 Answers2

0

Ok, then the problem is that the Name property of _status is not visible because it would conflict with the previous or the next sibling of the DataTemplate that was generated. Full description is here.

Community
  • 1
  • 1
0

I did some research and found that article. May be useful to someone. Easy to use!

http://www.dev102.com/2008/08/07/how-to-access-a-wpf-control-which-is-located-in-a-datatemplate/

arti
  • 645
  • 1
  • 8
  • 27