Click here to Skip to main content
15,914,905 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Binding the RichTextBox Pin
Mycroft Holmes7-Dec-10 11:19
professionalMycroft Holmes7-Dec-10 11:19 
GeneralRe: Binding the RichTextBox Pin
jadughar7-Dec-10 20:50
jadughar7-Dec-10 20:50 
GeneralRe: Binding the RichTextBox Pin
Mycroft Holmes7-Dec-10 22:21
professionalMycroft Holmes7-Dec-10 22:21 
GeneralRe: Binding the RichTextBox Pin
jadughar8-Dec-10 0:06
jadughar8-Dec-10 0:06 
AnswerRe: Binding the RichTextBox Pin
Pete O'Hanlon7-Dec-10 23:14
mvePete O'Hanlon7-Dec-10 23:14 
QuestionSilverlight 4.0 / VS2010 - Is it really that cool Pin
Roger1656-Dec-10 3:50
Roger1656-Dec-10 3:50 
AnswerRe: Silverlight 4.0 / VS2010 - Is it really that cool Pin
Abhinav S6-Dec-10 4:04
Abhinav S6-Dec-10 4:04 
QuestionWPF databinding - many to many - combobox, Entity Framework 4 [modified] Pin
Duke Carey6-Dec-10 2:49
professionalDuke Carey6-Dec-10 2:49 
Thanks in advance.

Without boring you to death with all the details - I have an EF model intended to track project requests. The hierarchy is that corporate divisions have departments; the departments submit project requests. The requests have to be categorized by risk and can fall into one or more categories. This last component is represented in the database via a Many-to-Many table incorporating the RequestIDs and the RiskIDs. EF eliminates the many-to-many table and shows the association between the Request and RiskCategory entities.

I've created a WPF form that ALMOST works they way I want, showing the users the details of their requests. I'd like to add to the form a combobox within a listview, from which the users can select the categories that apply to a given request. Only the combobox will be in the ListView

So..the CollectionViewSource for the RiskCategories table is categoriesViewSource, and the CollectionViewSource for the RequestItems is named
RequestItemsRiskCategoriesViewSource

The Datacontext of the ListView itself is set to RequestItemsRiskCategoriesViewSource, and the combobox's ItemsSource is set to the categoriesViewSource. Try as I might, I can only get the combox to display the available RiskCategories, not the ones already assigned to the current RequestItem. If there is one category assigned, then one combobox hows in the listview. If 3, then 3 comboxes appear. But each one displays the first category in the list, not the assigned categories.

Changing the datatemplate to a Textbox bound to Category works just fine, but gives the user no way to choose a valid value

<ListView.View>
    <GridView>
        <GridViewColumn x:Name="categoryColumn" Header="Category" Width="80">
            <GridViewColumn.CellTemplate>
                <DataTemplate>
                    <ComboBox
                        ItemsSource="{Binding Source={StaticResource categoriesViewSource}}"
                        SelectedValue="{Binding Path=RiskCategory}"
                        DisplayMemberPath="Category">

                    </ComboBox>
                </DataTemplate>
            </GridViewColumn.CellTemplate>
        </GridViewColumn>
    </GridView>
</ListView.View>


[edit] - I posted XAML from a listview, not a datagridview. I can get the listview to work, but not a datagridview
Any ideas what I'm doing wrong? Do I have to handle M-M relationships differently?


Thanks again

modified on Wednesday, December 8, 2010 3:22 PM

AnswerRe: WPF databinding - many to many - combobox, Entity Framework 4 Pin
eddieangel7-Dec-10 11:22
eddieangel7-Dec-10 11:22 
GeneralRe: WPF databinding - many to many - combobox, Entity Framework 4 Pin
Duke Carey15-Dec-10 1:39
professionalDuke Carey15-Dec-10 1:39 
QuestionHow to bind between listView with two column and database items ? Pin
Yanshof5-Dec-10 22:44
Yanshof5-Dec-10 22:44 
AnswerRe: How to bind between listView with two column and database items ? Pin
Pete O'Hanlon5-Dec-10 23:17
mvePete O'Hanlon5-Dec-10 23:17 
AnswerRe: How to bind between listView with two column and database items ? Pin
Abhinav S6-Dec-10 4:00
Abhinav S6-Dec-10 4:00 
QuestionHow do you handle the static data load Pin
Mycroft Holmes5-Dec-10 20:18
professionalMycroft Holmes5-Dec-10 20:18 
AnswerRe: How do you handle the static data load Pin
#realJSOP6-Dec-10 2:09
professional#realJSOP6-Dec-10 2:09 
GeneralRe: How do you handle the static data load Pin
Mycroft Holmes6-Dec-10 3:03
professionalMycroft Holmes6-Dec-10 3:03 
GeneralRe: How do you handle the static data load Pin
#realJSOP7-Dec-10 1:45
professional#realJSOP7-Dec-10 1:45 
GeneralRe: How do you handle the static data load Pin
Mycroft Holmes7-Dec-10 11:16
professionalMycroft Holmes7-Dec-10 11:16 
Questionevents between two threads Pin
igalep1325-Dec-10 8:03
igalep1325-Dec-10 8:03 
AnswerRe: events between two threads Pin
Mycroft Holmes5-Dec-10 10:51
professionalMycroft Holmes5-Dec-10 10:51 
GeneralRe: events between two threads Pin
igalep1325-Dec-10 10:53
igalep1325-Dec-10 10:53 
AnswerRe: events between two threads Pin
SledgeHammer015-Dec-10 11:02
SledgeHammer015-Dec-10 11:02 
GeneralRe: events between two threads Pin
igalep1325-Dec-10 11:05
igalep1325-Dec-10 11:05 
AnswerRe: events between two threads Pin
Ray Cassick7-Dec-10 9:03
Ray Cassick7-Dec-10 9:03 
GeneralRe: events between two threads Pin
igalep1327-Dec-10 9:56
igalep1327-Dec-10 9:56 

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.