Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] Custom Commands - Help!

Experienced Elementalist
Joined
Apr 12, 2009
Messages
241
Reaction score
32
For anyone who does wanna know about custom commands in WPF...

Code:
    public static class LibraryCommands
    {
        public static RoutedCommand OpenLibraryFolder = new RoutedCommand();
    }

    public partial class MainWindow
    {
        public void OpenLibraryFolderCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = true;
        }
        public void OpenLibraryFolderExecute(object sender, ExecutedRoutedEventArgs e)
        { 
            Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows),"explorer.exe"), "/root,"+App.Environment.Settings.PrimaryLibraryPath);
        }

<Window xmlns:local="clr-namespace:CoolProject" ...>
  <Window.CommandBindings>
<CommandBinding Command="{x:Static local:LibraryCommands.OpenLibraryFolder}" CanExecute="OpenLibraryFolderCanExecute" Executed="OpenLibraryFolderExecute" />
</Window.CommandBindings>
 
Back
Top