Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated Value in TreeDataGrid Cell #308

Open
mityamuch opened this issue Sep 20, 2024 · 0 comments
Open

Duplicated Value in TreeDataGrid Cell #308

mityamuch opened this issue Sep 20, 2024 · 0 comments

Comments

@mityamuch
Copy link

I have a treeDataGrid with templates for editing and reading. But the value in the last row is displayed twice on focus after clicking Tab. In other rows everything is ok. And it is a bit strange. What is the reason for this problem? How can I solve it?

image
image

My template for this cell in the tree:

 <TreeDataGrid Source="{Binding ViewModel.TreeDataGridSource}"
               CanUserResizeColumns="True"
               CanUserSortColumns="False" 
               AutoDragDropRows="False">
               <DataTemplate DataType="viewModels:TreeNodeViewModel" x:Key="VariableTextForRead">
    <Border Classes.Default="{Binding [Value], Converter={x:Static ObjectConverters.IsNull}}"
            Classes.Error="{Binding [Value], Converter={x:Static ObjectConverters.IsNotNull}}"
            ToolTip.Tip="{Binding [Value]}">
        <TextBlock Text="{Binding Value}"
                   VerticalAlignment="Center"
                   HorizontalAlignment="Stretch"
                   Padding="5,0"
                   ToolTip.Tip="{Binding [Value]}"/>
    </Border>
</DataTemplate>
<DataTemplate DataType="viewModels:TreeNodeViewModel" x:Key="VariableForEdit">
    <AutoCompleteBox x:Name="AutoCompleteBox"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"
                     Text="{Binding Value}"
                     ItemsSource="{Binding AvailableVariableNames, FallbackValue=?}"
                     FilterMode="ContainsOrdinal"
                     MinimumPopulateDelay="0"
                     MinimumPrefixLength ="1"
                     IsTextCompletionEnabled="False"
                     IsEnabled="{Binding CanValueBeEdited}"
                     IsVisible="{Binding !IsGroup}">
        <AutoCompleteBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding .}" Width="200"  TextTrimming="CharacterEllipsis" HorizontalAlignment="Left">
                </TextBlock>
            </DataTemplate>
        </AutoCompleteBox.ItemTemplate>
        <i:Interaction.Behaviors>
            <ia:EventTriggerBehavior EventName="Populating">
                <ia:InvokeCommandAction Command="{Binding Path=$parent[UserControl].((adapters:EditorPresenter)DataContext).PopulatingCommand, FallbackValue=?}"
                                        CommandParameter="{Binding UniqueGuid}"/>
            </ia:EventTriggerBehavior>
						<ia:EventTriggerBehavior EventName="LostFocus">
							<ia:InvokeCommandAction Command="{Binding Path=$parent[UserControl].((adapters:EditorPresenter)DataContext).ValueLostFocusCommand, FallbackValue=?}"
                                        CommandParameter="{Binding}" ></ia:InvokeCommandAction>
						</ia:EventTriggerBehavior>
        </i:Interaction.Behaviors>
    </AutoCompleteBox>
</DataTemplate>

My template for the tree:

private static HierarchicalTreeDataGridSource<TreeNodeViewModel> CreateTreeDataGridSource(
    IEnumerable<TreeNodeViewModel> parameters) =>
    new(parameters)
    {
        Columns =
        {
            new HierarchicalExpanderColumn<TreeNodeViewModel>(
                new TextColumn<TreeNodeViewModel, string>(Resources.NameStandardEditorHeader,
                    x => x.Name,options: new TextColumnOptions<TreeNodeViewModel>()
                    {
                        TextTrimming = TextTrimming.LeadingCharacterEllipsis,
                    }), x => x.Parameters),
            new TemplateColumn<TreeNodeViewModel>(Resources.ValueStandartEditorHeader,VariableReadEditTemplateResourceKey,
                VariableCellEditTemplateResourceKey, GridLength.Parse("*"),
                options: new TemplateColumnOptions<TreeNodeViewModel>
                {
                    BeginEditGestures = BeginEditGestures.Tap,
                }),
            new TemplateColumn<TreeNodeViewModel>(Resources.ChannelStandartEditorHeader, ChannelReadCellTemplateResourceKey,
                ChannelCellEditTemplateResourceKey, width: GridLength.Auto),
            new TextColumn<TreeNodeViewModel, string>(Resources.DataTypeStandartEditorHeader, x => x.DataType),
            new TemplateColumn<TreeNodeViewModel>(Resources.DefaultValueStandartEditorHeader,
                DefaultValueCellReadTemplateResourceKey,
                DefaultValueCellEditTemplateResourceKey),
            new TextColumn<TreeNodeViewModel, string>(Resources.MinValueStandartEditorHeader, x => x.MinValue),
            new TextColumn<TreeNodeViewModel, string>(Resources.MaxValueStandartEditorHeader, x => x.MaxValue),
            new TextColumn<TreeNodeViewModel, string>(Resources.DescriptionStandardEditorHeader,
                x => x.Description,
                GridLength.Auto,
                new TextColumnOptions<TreeNodeViewModel>
                {
                    TextWrapping = TextWrapping.Wrap,
                    TextAlignment = TextAlignment.Left,
                    BeginEditGestures = BeginEditGestures.DoubleTap
                })
        }
    };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant