Click here to Skip to main content
15,918,742 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF Design-Time Headaches Pin
SledgeHammer0110-Feb-14 12:04
SledgeHammer0110-Feb-14 12:04 
GeneralRe: WPF Design-Time Headaches Pin
GenJerDan11-Feb-14 5:20
GenJerDan11-Feb-14 5:20 
QuestionHitTest Problem Pin
Kevin Marois10-Feb-14 8:18
professionalKevin Marois10-Feb-14 8:18 
AnswerRe: HitTest Problem Pin
Jason Gleim10-Feb-14 9:41
professionalJason Gleim10-Feb-14 9:41 
QuestionLinq-To-SQL DBML Designer Question Pin
Kevin Marois10-Feb-14 7:11
professionalKevin Marois10-Feb-14 7:11 
QuestionMVVM Bound Radio Button Unexpected Behavior Pin
eddieangel7-Feb-14 12:08
eddieangel7-Feb-14 12:08 
AnswerRe: MVVM Bound Radio Button Unexpected Behavior Pin
Richard Deeming10-Feb-14 2:10
mveRichard Deeming10-Feb-14 2:10 
QuestionHow to get entire column values of a datagrid when datagrid column header check box is checked and bind those values to a datatable? Pin
abhinav12235-Feb-14 18:28
abhinav12235-Feb-14 18:28 
QuestionHwndHost & C++/CLI problem Pin
Super Lloyd4-Feb-14 3:09
Super Lloyd4-Feb-14 3:09 
QuestionXML Treeview NodeChanged event not triggering on attribute edit Pin
wilx2-Feb-14 22:49
wilx2-Feb-14 22:49 
AnswerRe: XML Treeview NodeChanged event not triggering on attribute edit Pin
wilx2-Feb-14 23:09
wilx2-Feb-14 23:09 
QuestionAnother real newbie question - wiring events to handlers not in the code-behind class Pin
Marc Clifton2-Feb-14 10:57
mvaMarc Clifton2-Feb-14 10:57 
AnswerRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Pete O'Hanlon2-Feb-14 11:27
mvePete O'Hanlon2-Feb-14 11:27 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Marc Clifton5-Feb-14 15:09
mvaMarc Clifton5-Feb-14 15:09 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Pete O'Hanlon5-Feb-14 23:15
mvePete O'Hanlon5-Feb-14 23:15 
AnswerRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_2-Feb-14 19:19
professional_Maxxx_2-Feb-14 19:19 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Mycroft Holmes3-Feb-14 3:05
professionalMycroft Holmes3-Feb-14 3:05 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_3-Feb-14 9:29
professional_Maxxx_3-Feb-14 9:29 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
Marc Clifton5-Feb-14 15:13
mvaMarc Clifton5-Feb-14 15:13 
GeneralRe: Another real newbie question - wiring events to handlers not in the code-behind class Pin
_Maxxx_5-Feb-14 15:26
professional_Maxxx_5-Feb-14 15:26 
QuestionHow do I wire Command to functions not in the view? Pin
Marc Clifton2-Feb-14 10:14
mvaMarc Clifton2-Feb-14 10:14 
QuestionHow to bind a dataset to a WPF richtextbox? Pin
fsunole0329-Jan-14 10:43
fsunole0329-Jan-14 10:43 
AnswerRe: How to bind a dataset to a WPF richtextbox? Pin
Wayne Gaylard30-Jan-14 1:07
professionalWayne Gaylard30-Jan-14 1:07 
QuestionHandling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z27-Jan-14 23:43
Piotr Z27-Jan-14 23:43 
Hi,

I'm trying to handle the RowEditEnding Event on my dataGrid that contains data from LINQ to SQL context. Datagrid contains following items:

XML
<DataGrid RowEditEnding="dtgMyList_RowEditEnding" ItemsSource="{Binding ListAllItems}" AutoGenerateColumns="False" Grid.Row="1" x:Name="dtgMyList" Margin="2,2,2,2"  VerticalAlignment="Top">
    <DataGrid.Columns>
        <DataGridTextColumn IsReadOnly="True" Binding="{Binding ArtikelID, NotifyOnSourceUpdated=True}"  Header="ID"/>
        <DataGridTextColumn IsReadOnly="False" Binding="{Binding ArtikelBeschreibung, UpdateSourceTrigger=LostFocus}" Header="Beschreibung"/>
        <DataGridTextColumn IsReadOnly="False" Binding="{Binding Gesperrt,UpdateSourceTrigger=LostFocus}" Header="Gesperrt"/>
    </DataGrid.Columns>
</DataGrid>


So far I'm able to implement the Event handling in code behind, but this is against MVVM Guidelines.

Current implementation:

In View

public delegate void RowEditIntercept(object sender, DataGridRowEditEndingEventArgs e);


public event RowEditIntercept MyRowChanged;


C#
private void dtgMyList_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
    MyDataDataSerice ser = new MyDataDataSerice(this);
    MyRowChanged(sender, e);

}



In MyDataService class

private MainWindow _window;

public MyDataDataSerice(MainWindow window)
{
    _window = window;
    this._window.MyRowChanged += new RowEditIntercept(DoEditMyRows);
}


internal void DoEditMyRows(object sender, DataGridRowEditEndingEventArgs e)
{
    if (e.EditAction == DataGridEditAction.Commit)
    {
        linqMyDataDataContext context = new linqMyDataDataContext();
        tblStammDaten stamm = e.Row.DataContext as tblStammDaten;

        var matchedData = (from em in context.GetTable<tblStammDaten>()
                           where em.ArtikelID == stamm.ArtikelID
                           select em).SingleOrDefault();

        matchedData.ArtikelBeschreibung = stamm.ArtikelBeschreibung;
        matchedData.Gesperrt = stamm.Gesperrt;
        context.SubmitChanges();

    }
}


If I understand correctly, I need to find a way to intercept the Event arguments (object sender, DataGridRowEditEndingEventArgs e).

How can I do this in my ViewModel withough writing code in the View?

Thanks in advance!
Piotr
AnswerRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 0:29
mvePete O'Hanlon28-Jan-14 0:29 

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.