1

ここに、メッセージフィールドにデータを入力する方法があります

   public List<MessageFieldViewModel> GetAllViewModelMsgFields()
    {
        messageFieldVModel = messageField.GetAllMessageField().Select(msgFields => new MessageFieldViewModel
        {
            Id = msgFields.Id,
            Code = msgFields.Code,
            Name = msgFields.Name,
            Position = msgFields.Position,
            Length = msgFields.Length,
            IsMapped = (transactionRuleList.Any(tr => tr.SourceElementId == msgFields.Id)),
            MappingRule = transactionRuleList.Any(mapRule => mapRule.SourceElementId 
                                                             == msgFields.Id)?

                          transactionRuleList.First(mapRule => mapRule.SourceElementId 
                                                               == msgFields.Id).MappingRule

                          : null
        })
    .ToList();
        return messageFieldVModel;
    }

私のグリッドでは、すべての値を表示したい:

  <DataGrid   ItemsSource="{Binding MessageFields}" Margin="4,0,380,6" Grid.Row="2"    AutoGenerateColumns="False"  IsReadOnly="True">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding Id}" />
                <DataGridTextColumn Header="Code" Binding="{Binding Code}" />
                <DataGridTextColumn Header="Field Name" Binding="{Binding Name}"/>
                <DataGridTextColumn Header="Position" Binding="{Binding Position}" />
                <DataGridTextColumn Header="Length" Binding="{Binding Length}" />
                <DataGridTemplateColumn Header="IsMapped">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox IsChecked="{Binding Path=IsMapped}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTextColumn Header="MappingRule" Binding="{Binding MappingRule}" /> 
            </DataGrid.Columns>
        </DataGrid>

// MessageField データの一部

        MessageField.Add(new MessageFieldModel(01, "GMSLEN", "MESSAGE LENGTH", 5, 4));
        MessageField.Add(new MessageFieldModel(01, "GMSDST", "MESSAGE DESTINATION", 9, 7));
        MessageField.Add(new MessageFieldModel(011, "GMSOR", "MESSAGE ORIGIN", 16, 7));

        MessageField.Add(new MessageFieldModel(02, "GMSLEN", "MESSAGE LENGTH", 5, 4));
        MessageField.Add(new MessageFieldModel(02, "GMSDST", "MESSAGE DESTINATION", 9, 7));
        MessageField.Add(new MessageFieldModel(012, "GMSOR", "MESSAGE ORIGIN", 16, 7));

// いくつかの変換ルール データ

        TranslationRule.Add(new TranslationRuleModel(01, 01, 690, "direct"));
        TranslationRule.Add(new TranslationRuleModel(01, 01, 690, null));

        TranslationRule.Add(new TranslationRuleModel(02, 02, 690, "direct"));
        TranslationRule.Add(new TranslationRuleModel(02, 02, 690, null));

        TranslationRule.Add(new TranslationRuleModel(03, 03, 690, "direct"));
        TranslationRule.Add(new TranslationRuleModel(03, 03, 690, null));

現在、グリッドには IsMapped の値が表示されていますが、MappingRule については、直接と null の両方も表示したいと考えています。現在、null は表示されません。誰かが私が間違っていることを理解するのを手伝ってくれますか?

4

2 に答える 2