Click here to Skip to main content
15,885,366 members
Home / Discussions / WPF
   

WPF

 
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 
I have written a general XML editor using a tree view with the help of code found around the net, but I want to fire an event after editing an attribute so that I can save the tree for Undo/Redo functionality, I have added 2 event handlers for NodeChanged and NodeInserted which fire when I load the XML file, but if I edit the attribute in the treeview in the textblock, the NodeChanged Event does not fire. Please could someone help me fire something off at this point so I can save info for UNDO purposes, I would prefer to only fire the event on the TextBox Losing focus ideally.

I am using a HierarchicalDataTemplate with a XmlDataProvider and MVVM

XAML

HTML
<Window.Resources>
    <HierarchicalDataTemplate x:Key="NodeTemplate">
        <StackPanel Orientation="Horizontal">
            <TextBlock x:Name="name" Text="" FontSize="14"/>
            <TextBlock x:Name="inter" Text=" " />
            <TextBox x:Name="value" Text="" FontSize="14"    />
        </StackPanel>
        <HierarchicalDataTemplate.ItemsSource>
            <Binding XPath="child::node()|attribute::*" />


        </HierarchicalDataTemplate.ItemsSource>
        <HierarchicalDataTemplate.Triggers>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="Element">
                <Setter TargetName="name" Property="Text" Value="{Binding Path=Name}"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="Text">
                <Setter TargetName="value" Property="Text" Value="{Binding Path=Value}"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="Attribute">
                <Setter TargetName="name" Property="Text" Value="{Binding Path=Name}"></Setter>
                <Setter TargetName="inter" Property="Text" Value=": "></Setter>
                <Setter TargetName="value" Property="Text" Value="{Binding Path=Value}"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="CDATA">
                <Setter TargetName="value" Property="Text" Value="{Binding Path=Value}"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="Comment">
                <Setter TargetName="value" Property="Text" Value="{Binding Path=Value}"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Path=NodeType}" Value="ProcessingInstruction">
               <Setter TargetName="value" Property="Text" Value="{Binding Path=Value}"></Setter>
            </DataTrigger>
        </HierarchicalDataTemplate.Triggers>
    </HierarchicalDataTemplate>
    <XmlDataProvider x:Key="xmlDataProvider"></XmlDataProvider>
</Window.Resources>
<Grid>
    <TreeView Margin="0,24,0,273"
              Name="treeView1"
              Background="AliceBlue"
              ItemsSource="{Binding Source={StaticResource xmlDataProvider}, XPath=*}"
              ItemTemplate= "{StaticResource NodeTemplate}"
              TreeViewItem.Selected="TreeViewItemSelected"
              SelectedItemChanged="SelectedItemChanged">

    </TreeView>
</Grid>



ViewModel

HTML
        public XMLDataViewerModel(bool largeRegisters, XmlDataProvider dataProvider)
        {
            DataProvider = dataProvider;
            DataProvider.Document = new XmlDocument();

            DataProvider.Document.NodeChanged += new XmlNodeChangedEventHandler(Document_NodeChanged);
            DataProvider.Document.NodeInserted += new XmlNodeChangedEventHandler(Document_NodeChanged);

            Undo = new Deque<XmlDocument>();
            Redo = new Deque<XmlDocument>();
            //            XDoc = DataProvider.Document;
        }

        void Document_NodeChanged(object sender, XmlNodeChangedEventArgs e)
        {
//            SaveForUndo();

        }

        void Document_NodeInserted(object sender, XmlNodeChangedEventArgs e)
        {
//            SaveForUndo();
        }

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 
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 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Piotr Z28-Jan-14 0:51
Piotr Z28-Jan-14 0:51 
GeneralRe: Handling RowEditEnding in a DataGrid according to MVVM pattern Pin
Pete O'Hanlon28-Jan-14 1:10
mvePete O'Hanlon28-Jan-14 1:10 

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.