Click here to Skip to main content
15,907,687 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Keep messagebox on top of window Pin
SledgeHammer014-Nov-11 7:15
SledgeHammer014-Nov-11 7:15 
GeneralRe: Keep messagebox on top of window Pin
WelshChris4-Nov-11 7:29
WelshChris4-Nov-11 7:29 
GeneralRe: Keep messagebox on top of window Pin
Wayne Gaylard4-Nov-11 8:11
professionalWayne Gaylard4-Nov-11 8:11 
QuestionWPF Pin
Unque4-Nov-11 3:06
Unque4-Nov-11 3:06 
AnswerRe: WPF Pin
Abhinav S4-Nov-11 3:15
Abhinav S4-Nov-11 3:15 
QuestionWPF Editable ComboBox In GridView Pin
Kevin Marois3-Nov-11 13:18
professionalKevin Marois3-Nov-11 13:18 
AnswerRe: WPF Editable ComboBox In GridView Pin
SledgeHammer013-Nov-11 16:13
SledgeHammer013-Nov-11 16:13 
GeneralRe: WPF Editable ComboBox In GridView Pin
Kevin Marois4-Nov-11 7:57
professionalKevin Marois4-Nov-11 7:57 
Ok, I've been working with this for a while and I'm not gtting it. This post is a bit long but explains things better than my first post.

I have a Query view in my app. The user can type in any search terms they want. In this screenshot I entered Item1 - Item5.
www.maroisconsulting.com/image/Query1.png[^]

When the user clicks the Apply button, what I want to happen is to hide the textbox and show the grid. Both are on the view. The textbox is initially visible and the grid is initially hidden.

The Apply method converts the search terms into a list of objects:
private void apply()
{
    // The property 'SearchTerms' is bound to the textbox. This converts the text into an array
    string[] temp = SearchTerms.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

    // Convert the array into a list
    var temp2 = (from s in temp
                    where s != string.Empty
                    select new SearchItemModel
                    {
                        SearchTerm = s,
                        Quantity = 1
                    }).ToList();

    // Store the list to the SearchItems property. This property is bound to the grid's ItemSource
    SearchItems = new ObservableCollection<SearchItemModel>(temp2);
                
    // Togggle the textbox & grid visibility
    GridVisible = true;
    TextAreaVisible = false;
}


There are 2 columns on the grid. The first column is an editable combobox. It's source of data is a list of project names stored in a collection called 'BOMs' (Bills of Materials), something like

Project A4472A
BOM Project B2215B
Some Other BOM


The user should then be able to either type in any text to search on, or select a BOM project name from the combox box.

Here's the relevant XAML:

<DataGrid x:Name="grdItems"
            Grid.Row="4"
            Grid.Column="0"
            Grid.ColumnSpan="2"
            AutoGenerateColumns="False"
            ItemsSource="{Binding SearchItems}"
            Visibility="{Binding GridVisible, Converter={StaticResource visibilityConverter}}"
            Margin="5">

    <DataGrid.Columns>
        <DataGridTemplateColumn Header="Search Terms"
                                Width="*">
            <DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <ComboBox Height="22" 
                                IsEditable="True"
                                ItemsSource="{Binding BOMs}"
                                SelectedItem="{Binding SelectedBOMItem}"></ComboBox>
                </DataTemplate>
            </DataGridTemplateColumn.CellEditingTemplate>
        </DataGridTemplateColumn>
        <DataGridTextColumn Header="Quantity" 
                            Binding="{Binding Quantity}"
                            Width="100">
        </DataGridTextColumn>
    </DataGrid.Columns>

</DataGrid>


After the Apply method runs, I get this: http://www.maroisconsulting.com/image/Query2.png[^]

What I would like to get is this (mocked up):
http://www.maroisconsulting.com/image/Query3.png[^]

Hope this made sense. Any thoughts on how to do this?

[UPDATE]
The Output window shows 2 errors:
"BindingExpression path error: 'BOMs' property not found on 'object' ''SearchItemModel' ("
"BindingExpression path error: 'SelectedBOMItem' property not found on 'object' ''SearchItemModel'"
Everything makes sense in someone's mind

GeneralRe: WPF Editable ComboBox In GridView Pin
SledgeHammer014-Nov-11 8:14
SledgeHammer014-Nov-11 8:14 
GeneralRe: WPF Editable ComboBox In GridView Pin
Kevin Marois4-Nov-11 8:18
professionalKevin Marois4-Nov-11 8:18 
GeneralRe: WPF Editable ComboBox In GridView Pin
SledgeHammer014-Nov-11 8:41
SledgeHammer014-Nov-11 8:41 
GeneralRe: WPF Editable ComboBox In GridView Pin
Kevin Marois4-Nov-11 8:49
professionalKevin Marois4-Nov-11 8:49 
GeneralRe: WPF Editable ComboBox In GridView Pin
SledgeHammer014-Nov-11 8:55
SledgeHammer014-Nov-11 8:55 
GeneralRe: WPF Editable ComboBox In GridView Pin
Kevin Marois4-Nov-11 9:01
professionalKevin Marois4-Nov-11 9:01 
GeneralRe: WPF Editable ComboBox In GridView Pin
SledgeHammer014-Nov-11 10:34
SledgeHammer014-Nov-11 10:34 
GeneralRe: WPF Editable ComboBox In GridView Pin
Kevin Marois6-Nov-11 7:02
professionalKevin Marois6-Nov-11 7:02 
GeneralRe: WPF Editable ComboBox In GridView Pin
SledgeHammer017-Nov-11 6:46
SledgeHammer017-Nov-11 6:46 
AnswerRe: WPF Editable ComboBox In GridView Pin
Abhinav S3-Nov-11 17:13
Abhinav S3-Nov-11 17:13 
QuestionColumnDefinition MinWidth=744 Pin
indian1432-Nov-11 14:57
indian1432-Nov-11 14:57 
AnswerRe: ColumnDefinition MinWidth=744 Pin
Abhinav S2-Nov-11 18:04
Abhinav S2-Nov-11 18:04 
QuestionTrying To Shutdown WPF App - Application.Current is null Pin
Kevin Marois2-Nov-11 6:55
professionalKevin Marois2-Nov-11 6:55 
AnswerRe: Trying To Shutdown WPF App - Application.Current is null Pin
SledgeHammer012-Nov-11 7:49
SledgeHammer012-Nov-11 7:49 
GeneralRe: Trying To Shutdown WPF App - Application.Current is null Pin
Kevin Marois2-Nov-11 8:38
professionalKevin Marois2-Nov-11 8:38 
GeneralRe: Trying To Shutdown WPF App - Application.Current is null Pin
SledgeHammer012-Nov-11 8:47
SledgeHammer012-Nov-11 8:47 
AnswerRe: Trying To Shutdown WPF App - Application.Current is null Pin
Pete O'Hanlon2-Nov-11 8:52
mvePete O'Hanlon2-Nov-11 8:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.