예제 #1
0
        public override void ShowDialog(PropertyItemValue propertyValue, IInputElement commandSource)
        {
            PropertyGrid propGrid = commandSource as PropertyGrid;
            string       lastPath = propertyValue.StringValue;

            if (propGrid == null)
            {
                return;
            }

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "All files (*.*)|*.*";
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog.ShowDialog();

            propertyValue.StringValue = openFileDialog.FileName != String.Empty ? openFileDialog.FileName : lastPath;             // change this string and compile, the ui does not see this change
            propGrid.DoReload();
            propGrid.RaiseEvent(new PropertyValueChangedEventArgs(PropertyGrid.PropertyValueChangedEvent, propertyValue.ParentProperty, ""));
        }