Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Windows Presentation Foundation
|
Windows Presentation Foundation Discussion of the beta version of Windows Presentation Foundation "WPF" formerly know as codename "Avalon" as well as the related XAML.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Windows Presentation Foundation section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2008, 10:26 AM
Registered User
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Binding ComboBox inside ListView problem

I am attempting to put a bound ComboBox into my ListView. However, I can not get it to bind correctly. All of the textboxes that are in the ListView bind without any issues, but the ComboBox has issues. I am binding to the DefaultView of a DataTable in the code-behind. I have verified that the field that I am trying to bind to exists, as I tested by putting a TextBox in place of the ComboBox when I initially created the ListView. Thanks in advance for any tips.

-----
The following line of code is what does the binding.
-----

child.ItemsSource = customBusinessProcessTables.Tables["process_rule_input_val"].DefaultView;

----
The following is the listview that I am attempting to bind to.
----

<ListView Margin ="0,20,0,0" x:Name="_processruleinputvalList" HorizontalAlignment="Left" Width="Auto" Height="120">
                                        <ListView.View>
                                          <GridView>
                                            <GridViewColumn Header="Name" Width="300">
                                              <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                  <Label Content="{Binding Path=table_and_field}" VerticalContentAlignment="Center"></Label>
                                                </DataTemplate>
                                              </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Operator" Width="55">
                                              <GridViewColumn.CellTemplate>
                                                <DataTemplate>

                                                  <ComboBox Name="mycombo" SelectedItem="{Binding Path=operator, Mode=TwoWay}" Width = "50">
                                                    <ComboBoxItem Content=""></ComboBoxItem>
                                                    <ComboBoxItem>EQ</ComboBoxItem>
                                                    <ComboBoxItem>NE</ComboBoxItem>
                                                    <ComboBoxItem>CH</ComboBoxItem>
                                                    <ComboBoxItem>GE</ComboBoxItem>
                                                    <ComboBoxItem>LE</ComboBoxItem>
                                                  </ComboBox>
                                                </DataTemplate>
                                              </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Value" Width="300">
                                              <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                  <TextBox Name="tbListLabelValue" IsReadOnly="False" TextWrapping="WrapWithOverflow" Width = "300" Text="{Binding Path=value}" VerticalContentAlignment="Center">
                                                  </TextBox>
                                                </DataTemplate>
                                              </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Created By" Width="100">
                                              <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                  <TextBox Name="tbListLabelValue" IsReadOnly="False" TextWrapping="WrapWithOverflow" Width = "100" Text="{Binding Path=created_by}" VerticalContentAlignment="Center">
                                                  </TextBox>
                                                </DataTemplate>
                                              </GridViewColumn.CellTemplate>
                                            </GridViewColumn>
                                            <GridViewColumn Header="Created Date" Width="100">
                                              <GridViewColumn.CellTemplate>
                                                <DataTemplate>
                                                  <TextBox Name="tbListLabelValue" IsReadOnly="False" TextWrapping="WrapWithOverflow" Width = "100" Text="{Binding Path=created_dttm}" VerticalContentAlignment="Center">
                                                  </TextBox>
                                                </DataTemplate>
                                              </GridViewColumn.CellTemplate>
                                            </GridViewColumn>

                                          </GridView>
                                        </ListView.View>
                                      </ListView>

 
Old July 17th, 2008, 02:13 PM
Registered User
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solution is here:

http://forums.msdn.microsoft.com/en-...-bf10fe846add/






Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate ListView From ComboBox Select eusanpe C# 4 August 20th, 2007 06:49 PM
CheckBox binding in ListView - Multiple events! dweezilb Windows Presentation Foundation 1 April 22nd, 2007 06:39 PM
Binding a comboBox to update a listView Amethyst1984 VB How-To 2 February 28th, 2006 03:07 PM
Issue Binding to ComboBox. lam_lvl VB.NET 2002/2003 Basics 1 February 22nd, 2006 09:38 PM
Embed ListView in Combobox (Urgent) HemaChaudhry VB.NET 0 January 2nd, 2006 09:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.