码迷,mamicode.com
首页 > 其他好文 > 详细

简单的拼成一个内有datagrid的combobox

时间:2014-06-21 11:40:50      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   http   tar   

                    <Border Height="22" BorderBrush="DarkGray" BorderThickness="1">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock x:Name="TesTextBox" Height="20" Width="154"/>
                            <Button Height="20" Width="14" Click="Button_Click">
                                <Popup x:Name="Popup1" Height="300" StaysOpen="False">
                                    <Border BorderBrush="DarkGray"  BorderThickness="1">
                                        <DataGrid x:Name="TestDataGrid" CanUserReorderColumns = "false"
                                                  IsReadOnly="True" SelectionChanged="TestDataGrid_SelectionChanged"/>
                                    </Border>
                                </Popup>
                            </Button>
                        </StackPanel>
                    </Border>

然后 datagrid进行item赋值

testDatagrid.ItemSource = ...

最后实现一下事件

private void Button_Click(object sender, RoutedEventArgs e)
        {
            Popup1.PlacementTarget = TesTextBox;
            Popup1.Placement= PlacementMode.Bottom;
            Popup1.IsOpen = true;
        }

        private void TestDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TesTextBox.Text = (TestDataGrid.SelectedItem as DataRowView).Row["c_Code"].ToString();
        }

搞定!

如图:

bubuko.com,布布扣

简单的拼成一个内有datagrid的combobox,布布扣,bubuko.com

简单的拼成一个内有datagrid的combobox

标签:style   class   blog   code   http   tar   

原文地址:http://www.cnblogs.com/Events/p/3794933.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!