问题
I need to find out how to pass a string to ComboBox
that's inside of a TemplateColumn
of a DataGrid
. The idea behind is that whenever I double-click on a TextBox
a Popup
appears and I select the new content of the TextBox
from it (ComboBox
inside a Popup
).
XAML
<DataGridTemplateColumn Header="unit">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBox Text="{Binding unit}" MouseDoubleClick="TextBox_MouseDoubleClick_1" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<!-- The columns in the grid are binded to DataTable-->
<!-- Popup -->
<Popup Name="unitpop" StaysOpen="True" VerticalOffset="-20" HorizontalOffset="30" Placement="Mouse" >
<Grid Width="100" Height="20" Background="Transparent" >
<ComboBox x:Name="unit_combo" ItemsSource="{Binding Source={StaticResource UnitListData}}" DisplayMemberPath="Name" SelectedValuePath="idunit" IsReadOnly="True" SelectionChanged="unit_combo_SelectionChanged" />
</Grid>
</Popup>
<!-- The ComboBox is binding an ObservableCollection -->
来源:https://stackoverflow.com/questions/16997173/wpf-set-the-content-of-datagrids-selected-templatecolumns-textbox