Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2085
TemplateColumn Always in Edit Mode
posted

I have seen a few posts on specific columns that can be set to always be in edit mode.  Is there a way to set a TemplateColumn to always be in edit mode?

Parents
  • 12875
    posted

    Hi Gary,

    The answer is yes.  I created a templatecolumn with separate ItemTemplate and EditorTemplate each bound to a property in my viewmodel that implements INotifyPropertyChanged.

    You’ll notice that the ItemTemplate is a TextBlock and the EditorTemplate is a TextBox. 

    <ig:TemplateColumn Key="UnitPrice"  >

        <ig:TemplateColumn.ItemTemplate>

            <DataTemplate>

                <TextBlock Text="{Binding UnitPrice}"  MouseLeftButtonDown="TextBlock_MouseLeftButtonDown"/>

            </DataTemplate>

        </ig:TemplateColumn.ItemTemplate>                  

        <ig:TemplateColumn.EditorTemplate>

            <DataTemplate>                          

                <TextBox Text="{Binding UnitPrice, Mode=TwoWay, UpdateSourceTrigger=Explicit}" HorizontalAlignment="Center"/>                         

            </DataTemplate>

         </ig:TemplateColumn.EditorTemplate>

    </ig:TemplateColumn> 

    Then I used the Editing settings for the grid and set the IsOnCellActiveEditingEnabled to true and IsMouseActionEditingEnabled to SingleClick so that as soon as you mouse click or tab into the cell, it is in edit mode.  I also set AllowEditing to Cell although you may want to use Row. 

    Please let me know if that helps you.

Reply Children