Jump to content

Archived

This topic is now archived and is closed to further replies.

TheOnlyDroid

C# WPF Collection [Items: 1]

Recommended Posts

Just something I decided to put together while I'm not remotely well, I'm not going to provide support for this... I'm not going to help anyone who may need assistance creating an application from it, or help fixing an issue... I'm providing the example AS IS without support,help or information... You can find the raw code below.

 

I'll be updating this collection as I see fit, this will include a Plugin interface and system for you guys to check out, I'm not the most experienced when it comes to plugin's and the interfaces and functions that should be visible to curators via an API, so you'll be learning it at the same rate I will, admittedly you'll have a visual representation as I'll be doing all the reading. (Great).

 

Download Link (Mediafire || 11KB): Here

 

 

Switchable Windows (RAW):

 

- ISwitchable (.cs)

   public interface ISwitchable
   {
       void UtilizeState(object state);
   }

 

- IPageSwitch (.cs)

   public static class IPageSwitch
   {
       public static MainWindow LocalMainWindow;

       public static void Switch(UserControl newpage)
       {
           LocalMainWindow.Navigate(newpage);
       }
       public static void Switch(UserControl newPage, object objectState)
       {
           LocalMainWindow.Navigate(newPage, objectState);
       }
   }

 

- MainWindow.xaml (.cs)

   public partial class MainWindow : Window
   {
       public MainWindow()
       {
           InitializeComponent();
           IPageSwitch.LocalMainWindow = this;
           IPageSwitch.Switch(new MainMenu());
       }

       public void Navigate(UserControl nextPage)
       {
           this.Content = nextPage;
       }

       public void Navigate(UserControl nextPage, object objectState)
       {
           this.Content = nextPage;
           ISwitchable s = nextPage as ISwitchable;
           if (s != null)
               s.UtilizeState(objectState);
           else
               throw new ArgumentException("Nextpage is not ISwitchable, and cannot be used. (" + nextPage.Name.ToString() + ")");
       }
   }

 

- Pages

 

I will not be placing the raw code here.. I'll display what you should do.. Create a UserControl anywhere in your solution I chose my folder and named it "Pages" and continued as follows.

 

public partial class {CLASS|CONTROL NAME} : UserControl, ISwitchable
{

}

Share this post


Link to post
Share on other sites


×
×
  • Create New...

Important Information

Please visit Terms of Use for our Terms of Use and Privacy Policy for our privacy policy