Ejemplo n.º 1
0
        private static void BrowseOpenFileExecute(Window window, ExecutedRoutedEventArgs e)
        {
            var tb     = (TextBox)e.OriginalSource;
            var filter = (e.Parameter as string) ?? "All Files (*.*)|*.*";

            var path = tb.GetValue(TextBox.TextProperty) as string;

            path = Dialogs.BrowseForFileOpen(new WindowInteropHelper(window).Handle, filter, path);
            if (path != null)
            {
                tb.SetCurrentValue(TextBox.TextProperty, path);
                var binding = BindingOperations.GetBindingExpressionBase(tb, TextBox.TextProperty);
                if (binding != null)
                {
                    binding.UpdateSource();
                }
            }
        }