开发者

Display 2 values in a WPF DataGridComboBoxColumn DisplayMemberPath

开发者 https://www.devze.com 2023-02-21 19:33 出处:网络
I have a series of objects representing some data point开发者_如何学编程s listed in a DataGridComboBoxColumn.Setting the DisplayMemeberPath property I can display a single value, say the x coordinate.

I have a series of objects representing some data point开发者_如何学编程s listed in a DataGridComboBoxColumn. Setting the DisplayMemeberPath property I can display a single value, say the x coordinate. What I would like to do though is display both the x and y coordinates in 'x, y' format. Any ideas on how to do this?


you should not use DisplayMemberPath, but instead use a DataTemplate, and a TemplateColumn

    <ComboBox>
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding First}" Margin="0,0,10,0" />
                    <TextBlock Text="{Binding Second}"/>
                </StackPanel>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号