Popup user control


hi,  putting quick little demo app , want have popup.  have user control defined

<usercontrol x:class="myapp.favorites"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

mc:ignorable="d"

d:designheight="300" d:designwidth="400"

width="200">

 

<grid x:name="layoutroot" background="white">

<stackpanel orientation="vertical" grid.column="0">

<listbox x:name="mylist" itemssource="{binding}">

<listbox.itemtemplate>

<datatemplate>

<hyperlinkbutton x:name="reportlink" content="{binding reportname}" navigateuri="{binding url}" targetname="_blank" margin="10,60,0,0" />

</datatemplate>

</listbox.itemtemplate>

</listbox>

<button x:name="btnclose" content="close" click="reportlink_click" width="50"></button>

</stackpanel>

</grid>

</usercontrol>

i want close popup when close button clicked never seems fire , not sure how close popup.  have thought this.close(); work doesn't. 

private void reportlink_click(object sender, routedeventargs e)

{

 this.close();

}

a button click on main page opens popup.

private void btndesc_click(object sender, routedeventargs e)

{

popup p = new popup();p.child = new favorites();

p.verticaloffset = 200;

p.horizontaloffset = 200;

p.isopen = true;

}

i stumped.  appreciated.

 

thanks,

rhonda 

 

you add event in favorite (popup) control fires when 1 of buttons clicked. can place popup control close in event.

favorites.xaml.cs:

 

public partial class favorites : usercontrol  {      public event eventhandler closed;        public favorites()      {          initializecomponent();      }        private void reportlink_click(object sender, routedeventargs e)      {          if (closed != null)              closed(this, new eventargs());      }  }
 

mainpage.xaml.cs:

 

public partial class mainpage : usercontrol      {          popup pfavorites;            public mainpage()          {              initializecomponent();                pfavorites = new popup();              pfavorites.verticaloffset = 200;              pfavorites.horizontaloffset = 200;          }            private void btndesc_click(object sender, routedeventargs e)          {              // close popup if opened              if (pfavorites.isopen)                  pfavorites.isopen = false;                favorites fav = new favorites();              fav.closed += new eventhandler(fav_closed);              pfavorites.child = fav;              pfavorites.isopen = true;           }            void fav_closed(object sender, eventargs e)          {              pfavorites.isopen = false;          }      }
  

another suggestion use childwindow instead of popup control.



Silverlight  >  Silverlight Controls and Silverlight Toolkit



Comments

Popular posts from this blog

Conditional formatting a graph vertical axis in SSRS 2012 charts

Register with Power BI failed

SQL server replication error Cannot find the dbo or user defined function........