wpf set the content of datagrid's selected templatecolumn's textbox

▼魔方 西西 提交于 2019-12-12 18:00:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!