none
WPF DataGridTextColumn data entry issue - can't type anything but spacebar, will accept pasted values. RRS feed

  • Question

  • I have a very basic DataGrid.DataGridTextColumn (the Description column and property) object that refuses to accept any data entry.  It is tied into a custom class object public property of string, there are NO validations in process, the stupid thing just refuses to allow alpha and numeric, and symbolic characters.  Only the space bar fires off the code property's set statement, as well as pasting in a value.  This is insane.  Does anybody have any ideas as to what is going on?  I tried forcing update mode from the default as well as validation modes to be turned off, all this has no effect.  Here is my object class and WPF.  The project is set to .Net 4.6.2 64bit.

    Public Class PackageItem
        Implements INotifyPropertyChanged
    
        Public Shared nextID As Long = 0
        Public Property ItemID As Long
        Public Property ItemName As String
    
        Private _Description As String
        Public Property Description As String
            Get
                Return _Description
            End Get
            Set(value As String)
                _Description = value
                RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Description"))
            End Set
        End Property
        Public Property Selected As Boolean = True
        Public Property ParentID As Long
        Public Property RowOrder As Integer
        Public Property Revision As String
        Public Property IsBOMOnly As Boolean = False
        'Public Property RevisionDefinition As Autodesk.Connectivity.WebServices.RevDef
        Public Property Category As Autodesk.Connectivity.WebServices.Cat
        Public Property vItem As Autodesk.Connectivity.WebServices.Item
        Public Property NumberingScheme As Autodesk.Connectivity.WebServices.NumSchm
        Public Property Files As New List(Of File)
        Public Property PreviousPackageItem As PackageItem
    
        Private booInVault As Boolean?
    
        Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    End Class
    

    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:local="clr-namespace:VaultDesignPackage" 
        mc:Ignorable="d" 
        x:Class="wdPackageItems"
        Title="Package Items" Height="1020" Width="1920">
        <Window.Resources>
            <CollectionViewSource x:Key="CategoriesViewSource" />
            <CollectionViewSource x:Key="PackageItemsViewSource" d:DesignSource="{d:DesignInstance {x:Type local:PackageItem}, CreateList=True}"/>
            <CollectionViewSource x:Key="PackageItemFilesViewSource" Source="{Binding Files, Source={StaticResource PackageItemsViewSource}}"/>
            <Style x:Key="StandardVerticalGridSplitter" TargetType="GridSplitter">
                <Setter Property="Width" Value="6"/>
                <Setter Property="ShowsPreview" Value="False"/>
                <Setter Property="VerticalAlignment" Value="Stretch"/>
                <Setter Property="HorizontalAlignment" Value="Center" />
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                            <GradientStop Color="#64696969" Offset="0" />
                            <GradientStop Color="#64696969" Offset="1" />
                            <GradientStop Color="#007F7F7F" Offset="0.5" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>
            <Style x:Key="StandardHorizontalGridSplitter" TargetType="GridSplitter">
                <Setter Property="Height" Value="6"/>
                <Setter Property="ShowsPreview" Value="True"/>
                <Setter Property="HorizontalAlignment" Value="Stretch"/>
                <Setter Property="Background">
                    <Setter.Value>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="#64696969" Offset="0" />
                            <GradientStop Color="#64696969" Offset="1" />
                            <GradientStop Color="#007F7F7F" Offset="0.5" />
                        </LinearGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Resources>
        <Grid DataContext="{StaticResource PackageItemsViewSource}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <ToolBar Grid.ColumnSpan="3" Grid.Row="0">
                <Button x:Name="btnCheckIn" Content="Create Package Items" Margin="10,2,10,2" Padding="20,2,2,2" Click="btnCheckIn_Click" BorderBrush="#00707070">
                    <Button.Background>
                        <ImageBrush ImageSource="Image/VaultCheckInFolder.bmp" Stretch="None" AlignmentX="Left" />
                    </Button.Background>
                </Button>
                <ToggleButton x:Name="chkSetReleased" Content="Release" Margin="10,0,10,0" HorizontalContentAlignment="Center" HorizontalAlignment="Left" IsChecked="True"/>
                <ToggleButton x:Name="chkEmail" Content="Email" Margin="10,0,10,0" HorizontalContentAlignment="Center" HorizontalAlignment="Left" IsChecked="True"/>
                <Button x:Name="btnGetFilesFromPreviousRevision" Content="Get Files From Previous Revision" Click="btnGetFilesFromPreviousRevision_Click" IsEnabled="{Binding /HasPreviousRevision}"/>
            </ToolBar>
            <DataGrid x:Name="dgPackageItem" AutoGenerateColumns="False" Grid.Row="1" Grid.Column="0" 
                      ItemsSource="{Binding}" RowDetailsVisibilityMode="VisibleWhenSelected"
                      IsReadOnly="False" CanUserAddRows="False" CanUserResizeRows="False">
                <DataGrid.Columns>
                    <DataGridTextColumn x:Name="ItemIDColumn" Binding="{Binding ItemID}" Header="Item ID" Width="SizeToHeader"/>
                    <DataGridTextColumn x:Name="ItemNameColumn" Binding="{Binding ItemName}" Header="Item Name" Width="*"/>
                    <DataGridTextColumn x:Name="DescriptionColumn" Binding="{Binding Path=Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, 
                        ValidatesOnDataErrors=False,ValidatesOnExceptions=False,ValidatesOnNotifyDataErrors=False}" Header="Description" Width="*"/>
                    <DataGridTextColumn x:Name="MasterIDColumn" Binding="{Binding MasterID}" Header="Master ID" IsReadOnly="True" Width="SizeToHeader"/>
                    <DataGridTextColumn x:Name="ParentIDColumn" Binding="{Binding ParentID}" Header="Parent ID" Width="SizeToHeader"/>
                    <DataGridTextColumn x:Name="RevisionColumn" Binding="{Binding Revision}" Header="Revision" Width="SizeToHeader"/>
                    <DataGridTextColumn x:Name="RowOrderColumn" Binding="{Binding RowOrder}" Header="Row Order" Width="SizeToHeader"/>
                    <DataGridCheckBoxColumn x:Name="SelectedColumn" Binding="{Binding Selected}" Header="Selected" Width="SizeToHeader"/>
                </DataGrid.Columns>
            </DataGrid>
            <GridSplitter Name="Splitter1" Grid.Row="1" Grid.Column="1" Style="{DynamicResource StandardVerticalGridSplitter}" />
            <DataGrid x:Name="dgFiles" AutoGenerateColumns="False" Grid.Row="1" Grid.Column="2" EnableRowVirtualization="True" 
                      ItemsSource="{Binding Source={StaticResource PackageItemFilesViewSource}}" 
                      RowDetailsVisibilityMode="VisibleWhenSelected" IsReadOnly="False" CanUserAddRows="False" CanUserResizeRows="False">
                <DataGrid.Columns>
                    <DataGridTextColumn x:Name="NameColumn" Binding="{Binding Name}" Header="Name" Width="*"/>
                    <DataGridTextColumn x:Name="VerNumColumn" Binding="{Binding VerNum}" Header="Ver Num" Width="SizeToHeader"/>
                    <DataGridTemplateColumn x:Name="CkInDateColumn" Header="Check In Date" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <DatePicker SelectedDate="{Binding CkInDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn x:Name="CreateDateColumn" Header="Create Date" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <DatePicker SelectedDate="{Binding CreateDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTemplateColumn x:Name="ModDateColumn" Header="Mod Date" Width="*">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <DatePicker SelectedDate="{Binding ModDate, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                </DataGrid.Columns>
            </DataGrid>
        </Grid>
    </Window>


    Jamie V Johnson

    • Moved by Bob Ding Thursday, March 1, 2018 6:47 AM not support Autodesk AutoCAD platform
    Friday, February 23, 2018 7:49 PM

All replies

  • Hi Jamie V Johnson,

    Sorry for my late reply.

    I can not reproduce your question, can you upload a screenshot or a whole simple demo which can reproduce the issue.

    Just test following property, it works fine.

        Public Property Description As String
            Get
                Return _Description
            End Get
            Set(value As String)
                _Description = value
                RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Description"))
            End Set
        End Property

    >> the stupid thing just refuses to allow alpha and numeric, and symbolic characters. 

    Does all of cells have this same behavior?

    >> Only the space bar fires off the code property's set statement, as well as pasting in a value. 

    I see Not all of your properties implement the INotifyPropertyChanged interface, Don't use Auto-properties if you want to get notification.

    Maybe you can use Binding::UpdateSourceTrigger Property to determines the timing of binding source updates

    https://msdn.microsoft.com/en-us/library/system.windows.data.binding.updatesourcetrigger(v=vs.110).aspx

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    • Edited by Bob Ding Monday, February 26, 2018 6:32 AM
    Monday, February 26, 2018 6:08 AM
  • So the problem is the hosting platform.  I've seen this before.  Autodesk Vault Professional's Extension platform, behaving similar to Autodesk AutoCAD platform.  When the Host UI is running a custom Window under the 'show' command it listens to all events from the keyboard and said listener cancels the event before any custom windows can see the event bubble up.  This is contrary to the WPF standard behavior, and unexpected.  More similar to the older Windows Forms behavior.  The work around many suggest is to open the window using the 'show dialog' command.  However, while this solved the problem of keyboard entry, it prevents the user from interacting with both your custom window and the platform host window at the same time.  AutoCAD created ways of locking the document, and hosting custom windows in palettes that help to alleviate this problem.  However Vault does not.  So my only current solution is to turn the data entry textbox (and yes all text box based controls exhibit the same problem) into a button, that then opens a dialog based inputbox (.net's InputBox suffices here), each time the user wants to change a value.  I'm open to better solutions, but re-writing Autodesk Vault isn't one of them, today.

    Thank you,

    jvj


    Jamie V Johnson

    Tuesday, February 27, 2018 7:29 PM