Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic button click (Read 1688 times)
Joe
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Jun 6th, 2012
button click
Jul 2nd, 2012 at 8:14am
Print Post  
The button code as shown below, when the diagram to save as XML file, then open the xml file ,But It doesn't work. I hope you can give me some help or Suggestion?


private void btn_Click(object sender, RoutedEventArgs e){
diagram.CustomBehavior = null;
diagram.Behavior = Behavior.Custom;
diagram.CustomNodeType = typeof(Button);
}

private void diagram_InitializeNode(object sender, NodeEventArgs e)
{

DiagramNode node = e.Node as DiagramNode;
node.EnabledHandles = AdjustmentHandles.All;
node.HandlesStyle = HandlesStyle.SquareHandles;
if (node != null)
{
Button tbox = node.UIElement as Button;
if (tbox != null)
{
tbox.Click +=new RoutedEventHandler(Button_Click);
}
}
}

void Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Test!");
        }
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: button click
Reply #1 - Jul 2nd, 2012 at 10:24am
Print Post  
InitializeNode is raised only when the user draws nodes interactively. If you implement your own serialization of hosted controls, you can attach to the button's Click event from the Diagram.DeserializeControl handler. Otherwise you will have to loop over diagram.Nodes after loading a file to attach the buttons' handlers.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Joe
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 21
Joined: Jun 6th, 2012
Re: button click
Reply #2 - Jul 3rd, 2012 at 2:55am
Print Post  
i see,  thank you!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint