c# - Get the combobox from data template in WPF DataGrid -


After a

I have a DataTemplate column

  & lt for a WPF data grid,  , Data Grid Name = "grdTest" ItemsSource = "{Binding Path = Test List, Mode = Dow, UpdatesSource Trigger = By Changing Property}" & gt; & Lt; DataGrid.Columns & gt; & Lt; DataGridTemplateColumn Width = "120" & gt; & Lt; DataGridTemplateColumn.Header & gt; & Lt; Text Block Text = "Test Name" Tooltip = "Test Name" width = "109" /> & Lt; /DataGridTemplateColumn.Header> & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; ComboBox name = "cbxTest" SelectedValue = "{Binding TestID, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}" DisplayMemberPath = "Test" SelectedValuePath = "TestID" SelectionChanged = "cbxTest_SelectionChanged_1" ItemSource = "{Binding Path = TestList}" & gt; & Lt; / ComboBox & gt; & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt; & Lt; /DataGrid.Columns> & Lt; / Data grid & gt;   

I am trying to get the element told in the cellEditEnding event of datagrid as below:

  FrameworkElement elmtTest = grdTest.Columns [ 7]. GetCellContent (e.Row); ContentPresenter myContentPresenter = FindVisualChild & lt; Content Viewer & gt; (ElmtTest); Datasamlite myDataTemplate = myContentPresenter.ContentTemplate; Combo box myComboBox = (combobox) myDataTemplate.FindName ("cbxTest", myContentPresenter);   

The LMTTist is the type of system. Windows Control. ContentPager But the content template offers zero. How do I get the ComboBox element in the DataGrid column?

I found it to work. It was a filthy mistake by my end. I found ComboBox near FindVisualChild Had to do

  Framework element elmtTest = grdTest.Column [7] .GetCellContent (E.RO); Combo box mycombobox = discoverable child & lt; Combo box & gt; (Almat Test);    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -