2017-07-17 8 views
1

、今は私がMainViewModelでコレクションを持っている

 View = new List<Group> 
      { 
       new Group 
       { 
        Name = "Sagar Yadwad",GroupName = string.Empty,IsEnabled = true,LdapStatus="Pending" 
       }, 
       new Group 
       { 
        Name = "Sagar Yadwad1",GroupName = string.Empty,IsEnabled = false,LdapStatus="Pending" 
       } 

      }; 
     View1 = new ListCollectionView(View); 

     View1.Filter = (e) => 
     { 
      Group g = e as Group; 
      return g.IsEnabled; 
     }; 

としてデータ項目のコレクションを明示的に追加された項目がありdatapresenter上のデータソースを設定することはできません、私は私のxamDataGridのに私の上記のViewModelを結合していますし、コードはようです続く: -

  <igDp:XamDataGrid x:Name="XamDataGridGroup" DataSource="{Binding View1}" Width="950" FontStyle="Normal" FontFamily="Siemens Sans" Background="#F2F2F2" RecordFilterDropDownPopulating="GroupDataGrid_OnRecordFilterDropDownPopulating" GroupByAreaLocation="None" AllowDrop="True" IsSynchronizedWithCurrentItem="True" UpdateMode="OnUpdate" > 
       <UserControl> 

       </UserControl> 
       <igDp:XamDataGrid.Resources> 
        <Style TargetType="{x:Type igDp:DataRecordPresenter}"> 
         <Setter Property="IsSelected" Value="{Binding DataItem.IsSelected, Mode=TwoWay}"/> 
        </Style> 
        <Style TargetType="Button" x:Key="{ComponentResourceKey {x:Type igDp:XamDataGrid}, ButtonStyle}" BasedOn="{StaticResource BaseButtonStyle}"/> 
        <Style TargetType="igWindows:PopupResizerBar" > 
         <Setter Property="Visibility" Value="Hidden"></Setter> 
        </Style> 
       </igDp:XamDataGrid.Resources> 
       <igDp:XamDataGrid.FieldLayoutSettings> 
        <igDp:FieldLayoutSettings AllowRecordFixing="No" 
             AllowDelete="False" 
             HighlightAlternateRecords="False" 
             RecordSelectorLocation="None" 
             SelectionTypeRecord="Single" 
             SelectionTypeCell="Single" FilterUIType="LabelIcons" 
             AutoGenerateFields="False" AllowFieldMoving="No" 
             RecordSelectorExtent="1"/> 
       </igDp:XamDataGrid.FieldLayoutSettings> 


       <igDp:XamDataGrid.FieldSettings > 
        <igDp:FieldSettings 
       LabelTextWrapping="NoWrap" 
       FilterLabelIconDropDownType="MultiSelectExcelStyle" 
       AllowRecordFiltering="True" AllowCellVirtualization="False" 
       AllowLabelVirtualization="False" Width="Auto" CellWidth="100" 
       CellMinWidth="50"/> 
       </igDp:XamDataGrid.FieldSettings> 
       <igDp:XamDataGrid.FieldLayouts> 
        <igDp:FieldLayout> 
         <!--<igDp:FieldLayout.Fields> 
       <igDp:Field Name="Name" AllowEdit="False" AllowRecordFiltering="True"></igDp:Field> 
      </igDp:FieldLayout.Fields>--> 
         <igDp:UnboundField Width="300" Label="{LocText props:Resources.GROUPLIST_NAME}" BindingPath="Name" ToolTip="{LocText props:Resources.GROUPLIST_NAME}"> 

          <igDp:UnboundField.Settings> 
           <igDp:FieldSettings> 
            <igDp:FieldSettings.LabelPresenterStyle > 
             <Style TargetType="igDp:LabelPresenter" BasedOn="{StaticResource GmsLabelStyle }"> 
              <Setter Property="AutomationProperties.AutomationId" Value="Groups_Column"></Setter> 
             </Style> 
            </igDp:FieldSettings.LabelPresenterStyle> 
            <igDp:FieldSettings.CellValuePresenterStyle> 
             <Style TargetType="{x:Type igDp:CellValuePresenter}"> 
              <Setter Property="Margin" Value="2"></Setter> 

              <Setter Property="Template"> 
               <Setter.Value> 
                <ControlTemplate TargetType="igDp:CellValuePresenter"> 
                <TextBlock TextAlignment="Left" Text="{Binding Path=DataContext.DataItem.Name, RelativeSource={ RelativeSource Mode=TemplatedParent}}" 
                  VerticalAlignment="Center" /> 
                 <!--Visibility="{Binding Path=Parent.IsNameChangeable}"/>--> 

                </ControlTemplate> 
               </Setter.Value> 
              </Setter> 
             </Style> 
            </igDp:FieldSettings.CellValuePresenterStyle> 
           </igDp:FieldSettings> 
          </igDp:UnboundField.Settings> 

         </igDp:UnboundField> 
         <igDp:UnboundField Width="350" Label="{LocText props:Resources.GROUPLIST_LDAP_USERS}" BindingPath="GroupName" ToolTip="{LocText props:Resources.GROUPLIST_LDAP_USERS}"> 

          <igDp:UnboundField.Settings> 
           <igDp:FieldSettings> 
            <igDp:FieldSettings.LabelPresenterStyle > 
             <Style TargetType="igDp:LabelPresenter" BasedOn="{StaticResource GmsLabelStyle }"> 
              <Setter Property="AutomationProperties.AutomationId" Value="Group_Name"></Setter> 
             </Style> 
            </igDp:FieldSettings.LabelPresenterStyle> 
            <igDp:FieldSettings.CellValuePresenterStyle> 
             <Style TargetType="{x:Type igDp:CellValuePresenter}"> 
              <Setter Property="Margin" Value="2"></Setter> 

              <Setter Property="Template"> 
               <Setter.Value> 
                <ControlTemplate TargetType="igDp:CellValuePresenter"> 
                 <TextBlock AllowDrop="True" Text="{Binding Path=DataContext.DataItem.GroupName, RelativeSource={ RelativeSource Mode=TemplatedParent}}" 
                  VerticalAlignment="Center" TextAlignment="Center" /> 
                 <!--Visibility="{Binding Path=Parent.IsNameChangeable}"/>--> 

                </ControlTemplate> 
               </Setter.Value> 
              </Setter> 
             </Style> 
            </igDp:FieldSettings.CellValuePresenterStyle> 
           </igDp:FieldSettings> 
          </igDp:UnboundField.Settings> 

         </igDp:UnboundField> 
         <igDp:UnboundField Width="100" Label="{LocText props:Resources.GROUPLIST_SYNC}" BindingMode="TwoWay" BindingPath="IsEnabled" Converter="{StaticResource BoolToUMDirectoryFilter}" ConverterParameter="Enabled" ToolTip="{LocText props:Resources.GROUPLIST_SYNC}"> 
          <igDp:UnboundField.Settings> 
           <igDp:FieldSettings AllowEdit="True"> 
            <igDp:FieldSettings.LabelPresenterStyle > 
             <Style TargetType="igDp:LabelPresenter" BasedOn="{StaticResource GmsLabelStyle }"> 
              <Setter Property="AutomationProperties.AutomationId" Value="Group_SYNC"></Setter> 
             </Style> 
            </igDp:FieldSettings.LabelPresenterStyle> 
            <igDp:FieldSettings.CellValuePresenterStyle> 
             <Style TargetType="{x:Type igDp:CellValuePresenter}"> 
              <Setter Property="Margin" Value="2"></Setter> 
              <Setter Property="Template"> 
               <Setter.Value> 
                <ControlTemplate TargetType="igDp:CellValuePresenter"> 
                 <CheckBox IsChecked="{Binding Path=DataContext.DataItem.IsEnabled, RelativeSource={ RelativeSource Mode=TemplatedParent}}" 
                  HorizontalAlignment="Center" HorizontalContentAlignment="Center" Click="ButtonBase_OnClick"> 

                 </CheckBox> 
                </ControlTemplate> 
               </Setter.Value> 
              </Setter> 
             </Style> 
            </igDp:FieldSettings.CellValuePresenterStyle> 
           </igDp:FieldSettings> 
          </igDp:UnboundField.Settings> 
         </igDp:UnboundField> 
        <igDp:UnboundField Width="140" Label="{LocText props:Resources.GROUPLIST_LDAP_STATUS}" BindingPath="LdapStatus" ToolTip="{LocText props:Resources.GROUPLIST_LDAP_STATUS}"> 

         <igDp:UnboundField.Settings> 
          <igDp:FieldSettings> 
           <igDp:FieldSettings.LabelPresenterStyle > 
            <Style TargetType="igDp:LabelPresenter" BasedOn="{StaticResource GmsLabelStyle }"> 
             <Setter Property="AutomationProperties.AutomationId" Value="Group_Status"></Setter> 
            </Style> 
           </igDp:FieldSettings.LabelPresenterStyle> 
           <igDp:FieldSettings.CellValuePresenterStyle> 
            <Style TargetType="{x:Type igDp:CellValuePresenter}"> 
             <Setter Property="Margin" Value="2"></Setter> 

             <Setter Property="Template"> 
              <Setter.Value> 
               <ControlTemplate TargetType="igDp:CellValuePresenter"> 
                <TextBlock Text="{Binding Path=DataContext.DataItem.LdapStatus, RelativeSource={ RelativeSource Mode=TemplatedParent}}" 
                  VerticalAlignment="Center" TextAlignment="Center"/> 
                <!--Visibility="{Binding Path=Parent.IsNameChangeable}"/>--> 

               </ControlTemplate> 
              </Setter.Value> 
             </Setter> 
            </Style> 
           </igDp:FieldSettings.CellValuePresenterStyle> 
          </igDp:FieldSettings> 
         </igDp:UnboundField.Settings> 

        </igDp:UnboundField> 
       </igDp:FieldLayout> 
       </igDp:XamDataGrid.FieldLayouts> 
      </igDp:XamDataGrid> 

I「の項目は、データ項目のコレクションを明示的に追加しましたdatapresenter上のデータソースを設定することはできません」、というエラーを取得しています。どんな助けでも大歓迎です。事前に おかげで、 サーガルYadwad

答えて

1

XamDataGridからUserControlを削除するには:

<igDp:XamDataGrid x:Name="XamDataGridGroup" DataSource="{Binding View1}" ...> 
    <UserControl> 

    </UserControl> 
... 
+1

おかげでたくさんお返事のための私のための魅力のように働いた:) –

関連する問題