Click here to Skip to main content
15,910,661 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Diagonal text input and presentation in WPF Pin
SledgeHammer0124-Feb-14 11:53
SledgeHammer0124-Feb-14 11:53 
QuestionTheme Highlighting in XAML Pin
Kevin Marois20-Feb-14 5:09
professionalKevin Marois20-Feb-14 5:09 
QuestionWpf ScrollViewer with non scrollable or partially non scrollable Control Pin
BMicka19-Feb-14 22:06
BMicka19-Feb-14 22:06 
QuestionDataTemplate from a StaticResource Pin
Mycroft Holmes18-Feb-14 18:44
professionalMycroft Holmes18-Feb-14 18:44 
Questionremove double line of ListView Pin
Member 1001614013-Feb-14 1:45
Member 1001614013-Feb-14 1:45 
QuestionWPF Design-Time Headaches Pin
GenJerDan10-Feb-14 10:16
GenJerDan10-Feb-14 10:16 
AnswerRe: WPF Design-Time Headaches Pin
Jason Gleim10-Feb-14 10:34
professionalJason Gleim10-Feb-14 10:34 
GeneralRe: WPF Design-Time Headaches Pin
GenJerDan10-Feb-14 11:10
GenJerDan10-Feb-14 11:10 
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 
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 

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.