Home Forums WPF controls Xceed Toolkit Plus for WPF PropertyGrid default folder.

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • darrenrobertsuk
    Participant
    Post count: 3
    #44361 |

    Is there a way to select a default folder for a PropertyGrid File Editor?

    I’m currently adding this attribute to my properties which handles everything.

    [Editor(typeof (Xceed.Wpf.Toolkit.PropertyGrid.Editors.FileEditor), typeof (Xceed.Wpf.Toolkit.PropertyGrid.Editors.FileEditor))]

    Thanks in advance

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,
    If your property is of type “FileInfo”, you will end up with a Xceed.Wpf.Toolkit.PropertyGrid.Editors.FileEditor by default, without the need to set an attribute editor.

    If you want to use the Xceed.Wpf.Toolkit.PropertyGrid.Editors.FileEditor and you want this editor to point to a default folder when you open it, you can set the InitialDirectory property. You can do this like this :

    <Window x:Class=”WpfApplication74.MainWindow”
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    xmlns:d=”http://schemas.microsoft.com/expression/blend/2008&#8243;
    xmlns:mc=”http://schemas.openxmlformats.org/markup-compatibility/2006&#8243;
    xmlns:local=”clr-namespace:WpfApplication74″
    xmlns:s=”clr-namespace:System;assembly=mscorlib”
    xmlns:io=”clr-namespace:System.IO;assembly=mscorlib”
    xmlns:xctk=”http://schemas.xceed.com/wpf/xaml/toolkit&#8221;
    mc:Ignorable=”d”
    Title=”MainWindow” Height=”350″ Width=”525″>
    <Grid>
    <xctk:PropertyGrid x:Name=”_propertyGrid”
    SelectedObject=”{Binding}”
    Width=”450″
    MaxHeight=”320″
    Margin=”10″>
    <xctk:PropertyGrid.EditorDefinitions>
    <xctk:EditorIntegerUpDownDefinition TargetProperties=”{x:Type s:Int32}”
    TextAlignment=”Right” />
    <xctk:EditorFilePickerDefinition TargetProperties=”{x:Type io:FileInfo}”
    InitialDirectory=”C:\Logs” />
    </xctk:PropertyGrid.EditorDefinitions>
    </xctk:PropertyGrid>
    </Grid>
    </Window>

    namespace WpfApplication74
    {
    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();

    this.DataContext = new MyObject() { Age = 13 };
    }
    }

    public class MyObject
    {
    public int Age
    {
    get;
    set;
    }
    public FileInfo File
    {
    get;
    set;
    }
    }
    }

    You could also define your editor for FileInfo this way :
    <xctk:EditorTemplateDefinition TargetProperties=”{x:Type io:FileInfo}”>
    <xctk:EditorTemplateDefinition.EditingTemplate>
    <DataTemplate>
    <xctk:FilePicker SelectedFile=”{Binding Value}”
    InitialDirectory=”C:\Logs” />
    </DataTemplate>
    </xctk:EditorTemplateDefinition.EditingTemplate>
    </xctk:EditorTemplateDefinition>

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.