wpf set the content of datagrid's selected tem

2019-07-18 18:23发布

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 -->

0条回答
登录 后发表回答