Showing posts with label WPF. Show all posts
Showing posts with label WPF. Show all posts

Monday, August 8, 2016

wpf center a popup

PowerOff PO = new PowerOff();
            PO.Owner = Application.Current.MainWindow;            PO.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            PO.Show();

Tuesday, July 26, 2016

using sound in wpf

add wav file as Embedded Resource in file structure for e.g. resources/sounds.blah.wav

var _assembly = Assembly.GetExecutingAssembly();
                SoundPlayer sp = new SoundPlayer(_assembly.GetManifestResourceStream("Blah.Resources.Sounds.Blah.wav"));

                sp.Play();

wpf code upon closing app

public partial class App : Application
    {
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            blah.ShutDown(); 
        }

    }

adding email link to wpf form

<Hyperlink NavigateUri="mailto:blah@blah.net" RequestNavigate="OnNavigate">blah@blah.net</Hyperlink>

private void OnNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(e.Uri.AbsoluteUri);
            e.Handled = true;

        }

Thursday, July 21, 2016

wpf getting which button was clicked

MouseEventArgs me = (MouseEventArgs)e;

if(me.LeftButton== MouseButtonState.Pressed)  //left

get the control that has the context menu

MenuItem mnu = sender as MenuItem;
      
        if (mnu != null)
        {

            Button button = ((ContextMenu)mnu.Parent).PlacementTarget as Button;

wpf rtb ScrollToEnd not working

this is a workaround


  _textbox.Focus();
                 
                    TextPointer caretPos = _textbox.CaretPosition;
                    caretPos = caretPos.DocumentEnd;
                    _textbox.CaretPosition = caretPos;

Wednesday, July 20, 2016

dont run selected change event on load

i added the events after filling the combo boxes on loading

Tuesday, July 19, 2016

wpf form with only close button

this.ResizeMode = System.Windows.ResizeMode.NoResize;