John's little part of the web

John's home page

2014-04-11 08:26:27

I am always trying find, remember, or use these commands so here is a list for refrence.

source

ApplicationCommands
ApplicationCommands.CancelPrint
ApplicationCommands.Close
ApplicationCommands.ContextMenu
ApplicationCommands.Copy
ApplicationCommands.CorrectionList
ApplicationCommands.Cut
ApplicationCommands.Delete
ApplicationCommands.Find
ApplicationCommands.Help
ApplicationCommands.New
ApplicationCommands.NotACommand
ApplicationCommands.Open
ApplicationCommands.Paste
ApplicationCommands.Print
ApplicationCommands.PrintPreview
ApplicationCommands.Properties
ApplicationCommands.Redo
ApplicationCommands.Replace
ApplicationCommands.Save
ApplicationCommands.SaveAs
ApplicationCommands.SelectAll
ApplicationCommands.Stop
ApplicationCommands.Undo

NavigationCommands
NavigationCommands.BrowseBack
NavigationCommands.BrowseForward
NavigationCommands.BrowseHome
NavigationCommands.BrowseStop
NavigationCommands.DecreaseZoom
NavigationCommands.Favorites
NavigationCommands.FirstPage
NavigationCommands.GoToPage
NavigationCommands.IncreaseZoom
NavigationCommands.LastPage
NavigationCommands.NavigateJournal
NavigationCommands.NextPage
NavigationCommands.PreviousPage
NavigationCommands.Refresh
NavigationCommands.Search
NavigationCommands.Zoom

ComponentCommands
ComponentCommands.ExtendSelectionDown
ComponentCommands.ExtendSelectionLeft
ComponentCommands.ExtendSelectionRight
ComponentCommands.ExtendSelectionUp
ComponentCommands.MoveDown
ComponentCommands.MoveFocusBack
ComponentCommands.MoveFocusDown
ComponentCommands.MoveFocusForward
ComponentCommands.MoveFocusPageDown
ComponentCommands.MoveFocusPageUp
ComponentCommands.MoveFocusUp
ComponentCommands.MoveLeft
ComponentCommands.MoveRight
ComponentCommands.MoveToEnd
ComponentCommands.MoveToHome
ComponentCommands.MoveToPageDown
ComponentCommands.MoveToPageUp
ComponentCommands.MoveUp
ComponentCommands.ScrollByLine
ComponentCommands.ScrollPageDown
ComponentCommands.ScrollPageLeft
ComponentCommands.ScrollPageRight
ComponentCommands.ScrollPageUp
ComponentCommands.SelectToEnd
ComponentCommands.SelectToHome
ComponentCommands.SelectToPageDown
ComponentCommands.SelectToPageUp

MediaCommands
MediaCommands.BoostBass
MediaCommands.ChannelDown
MediaCommands.ChannelUp
MediaCommands.DecreaseBass
MediaCommands.DecreaseMicrophoneVolume
MediaCommands.DecreaseTreble
MediaCommands.DecreaseVolume
MediaCommands.FastForward
MediaCommands.IncreaseBass
MediaCommands.IncreaseMicrophoneVolume
MediaCommands.IncreaseTreble
MediaCommands.IncreaseVolume
MediaCommands.MuteMicrophoneVolume
MediaCommands.MuteVolume
MediaCommands.NextTrack
MediaCommands.Pause
MediaCommands.Play
MediaCommands.PreviousTrack
MediaCommands.Record
MediaCommands.Rewind
MediaCommands.Select
MediaCommands.Stop
MediaCommands.ToggleMicrophoneOnOff
MediaCommands.TogglePlayPause

2012-04-11 02:14:24

I have the following code to move to the next control if the return is entered

private void TextBox_PreviewKeyUp(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Return)
    {
        e.Handled = true;
        ((TextBox)sender).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    }
}

 

2012-02-28 06:56:45

Seems the IsReadOnly option does not work as expected on the ComboBox.  After a little searching I found that the IsReadOnly option affect the ablity of the user to edit the text in the ComboBox but does not affect the user's ablity to change the selection which is what I wanted.

To work around this first you need to set the IsHitTestVisible to false, setting this option to false means that none of the mouse events are sent to the control so the user can not select a new option.

This does not stop the user for tabing to the control and selecting a new option with the keypad.  So to stop the user from using the keypad I set the IsTabStop option to false also.  This way this control is not on the tab list which means it can't be selected.

So by setting both option the user can not longer change the option in the ComboBox.

2012-01-30 09:51:07

All application I write have to have a setting file which means they have to be upgraded.  Below is the basic code I stick in all my projects.

I add version number to setting and then check that against the version number in application and run the upgraded if needed.

In App.xaml.cs I add the follow to the OnStartup and OnExit override to update and save the settings.

Note that since by default the system does not add forms I add the System.Windows.Forms to the reference to see product version.

protected override void OnStartup(StartupEventArgs e)
{
    try
    {
        CoinAnalyzer.Properties.Settings.Default.Reload();
        if (CoinAnalyzer.Properties.Settings.Default.VersionNumber != System.Windows.Forms.Application.ProductVersion)
        {
            CoinAnalyzer.Properties.Settings.Default.Upgrade();
            CoinAnalyzer.Properties.Settings.Default.VersionNumber = System.Windows.Forms.Application.ProductVersion;
            CoinAnalyzer.Properties.Settings.Default.Save();
        }
    }
    catch (Exception ex)
    {
        TraceError("Error loading settings", TraceTypes.App, ex);
    }
   
    base.OnStartup(e);
}

protected override void OnExit(ExitEventArgs e)
{
    try
    {
        CoinAnalyzer.Properties.Settings.Default.Save();
    }
    catch (Exception ex)
    {
        TraceError("Error saving settings", TraceTypes.App, ex);
    }

    base.OnExit(e);
}

 

 

2012-01-30 08:55:16

 Whenever I create a new class that will be view in WPF and have the values change in the background I add the following.

The INotifyPropertyChanged give a hook for the WPF to pull on which then then link to the PropertyChanged event handle.

Each property then has to have a changed event sent to it, an empty property name will notify WPF that all properties have changed.

public class DataLink : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;
    private void SendPropertyChanged(String propertyName)
    {
        if ((this.PropertyChanged != null))
        {
            this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
    }

    private string _Field1;
    public string Field1
    {
        get { return this._Field1; }
        set { this._Field1 = value; this.SendPropertyChanged("Field1"); }
    }
}

2012-01-06 07:43:14

I use the following for alignment in the WPF DataGrid Columns.

First set a style in the resources for either the window or the user control.

Note you can add other properties here if needed.

<Window.Resources>
    <Style x:Key="StyleAlignRight"
           TargetType="{x:Type TextBlock}">
        <Setter Property="TextAlignment"
                Value="Right" />
    </Style>
    <Style x:Key="StyleAlignCenter"
           TargetType="{x:Type TextBlock}">
        <Setter Property="TextAlignment"
                Value="Center" />
    </Style>
</Window.Resources>

Then in the datagrid column set the element style

<DataGridTextColumn Header="Calls"
                    ElementStyle="{StaticResource StyleAlignRight}"
                    Binding="{Binding Path=DailyCalls, StringFormat=N0, Mode=TwoWay}"
                    MinWidth="50"
                    CanUserSort="True"  />

 

2011-12-28 06:35:22

I am not sure why it is not exposed but if you want to check if you are on the same thread as the current form you need to use the dsipatcher check access.

void BillboxHolder_ProgressChanged(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
    if (this.LayoutRoot.Dispatcher.CheckAccess())
    {
       this.ProgressBox_Status.Visibility = Visibility.Visible;
       this.ProgressBox_Status.Value = e.ProgressPercentage;
       this.TextBlock_Status.Text = "Processing...";
    }
    else
    {
       this.LayoutRoot.Dispatcher.Invoke(new EventHandler(BillboxHolder_ProgressChanged), new object[] { sender, e });
    }
}

Search using bing

this is a test