diff --git a/source/InPlaceEditBoxDemo/MainWindow.xaml b/source/InPlaceEditBoxDemo/MainWindow.xaml
index c21711e..33a6667 100644
--- a/source/InPlaceEditBoxDemo/MainWindow.xaml
+++ b/source/InPlaceEditBoxDemo/MainWindow.xaml
@@ -127,7 +127,7 @@
Text="{Binding Path=DisplayName, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{Binding Description, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
Focusable="True"
-
+ IsFileName="{Binding IsFile}"
VerticalAlignment="Stretch"
HorizontalAlignment="Left"
IsReadOnly="{Binding IsReadOnly}"
diff --git a/source/InplaceEditBoxLib/Views/EditBox.xaml.cs b/source/InplaceEditBoxLib/Views/EditBox.xaml.cs
index bc7b34c..18a2a97 100644
--- a/source/InplaceEditBoxLib/Views/EditBox.xaml.cs
+++ b/source/InplaceEditBoxLib/Views/EditBox.xaml.cs
@@ -88,6 +88,16 @@ public class EditBox : Control
typeof(EditBox),
new FrameworkPropertyMetadata(false));
+ ///
+ /// Dependency property for indicating if the edited data is a file name.
+ ///
+ private static readonly DependencyProperty IsFileNameProperty =
+ DependencyProperty.Register(
+ "IsFileName",
+ typeof(bool),
+ typeof(EditBox),
+ new FrameworkPropertyMetadata(false) );
+
///
/// Send a Rename command request to the ViewModel if renaming has been executed
///
@@ -325,6 +335,15 @@ public bool IsReadOnly
set { SetValue(mIsReadOnlyProperty, value); }
}
+ ///
+ /// Indicates if the edited data is a file name.
+ ///
+ public bool IsFileName
+ {
+ get { return (bool) GetValue(IsFileNameProperty); }
+ set { SetValue(IsFileNameProperty, value); }
+ }
+
///
/// Gets the scrollviewer in which this control is embeded.
///
@@ -550,10 +569,7 @@ private void TextBlock_LeftMouseDown(object sender, MouseButtonEventArgs e)
{
this.OnSwitchToEditingMode();
- var t = _TextBox as TextBox;
-
- if (t != null)
- t.SelectAll();
+ this.PrepareInitialEditSelection();
}
e.Handled = false;
@@ -571,11 +587,27 @@ private void ViewModel_RequestEdit(object sender, Events.RequestEdit e)
{
this.OnSwitchToEditingMode();
- var t = _TextBox as TextBox;
+ this.PrepareInitialEditSelection();
+ }
+ }
- if (t != null)
- t.SelectAll();
+ private void PrepareInitialEditSelection()
+ {
+ if(_TextBox == null)
+ {
+ return;
}
+ else if(IsFileName)
+ {
+ var fileExtensionIndex = _TextBox.Text.LastIndexOf('.');
+ if(fileExtensionIndex > 0)
+ {
+ _TextBox.Select(0, fileExtensionIndex);
+ return;
+ }
+ }
+
+ _TextBox.SelectAll();
}
#region ShowNotification
diff --git a/source/Solution/SolutionLib/Interfaces/IItem.cs b/source/Solution/SolutionLib/Interfaces/IItem.cs
index 4c1b3c4..9033d5a 100644
--- a/source/Solution/SolutionLib/Interfaces/IItem.cs
+++ b/source/Solution/SolutionLib/Interfaces/IItem.cs
@@ -44,6 +44,11 @@ public interface IItem : IEditBox, IViewModelBase, IParent
///
bool IsReadOnly { get; }
+ ///
+ /// Gets whether the item represents a file-like item.
+ ///
+ bool IsFile { get; }
+
///
/// Gets/sets a string that determines the order in which items are displayed.
///
diff --git a/source/Solution/SolutionLib/ViewModels/Browser/Base/ItemViewModel.cs b/source/Solution/SolutionLib/ViewModels/Browser/Base/ItemViewModel.cs
index 0a76739..f61944c 100644
--- a/source/Solution/SolutionLib/ViewModels/Browser/Base/ItemViewModel.cs
+++ b/source/Solution/SolutionLib/ViewModels/Browser/Base/ItemViewModel.cs
@@ -159,6 +159,17 @@ private set
}
}
+ ///
+ /// Gets whether the item represents a file-like item.
+ ///
+ public bool IsFile
+ {
+ get
+ {
+ return this.ItemType == Models.SolutionItemType.File;
+ }
+ }
+
///
/// Gets the parent object where this object is the child in the treeview.
///