gpt4 book ai didi

c# - 如何将列表绑定(bind)到 Data Grids 数据源的子类中的组合框?

转载 作者:行者123 更新时间:2023-12-03 10:40:30 26 4
gpt4 key购买 nike

到目前为止,这是我的 DxGrid 代码:

<dxg:GridControl x:Name="gridControlItemsDistinct" 
VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Height="Auto" Width="Auto"
AutoPopulateColumns="False"
DataSource="{Binding Path=ChaseListHelperClassItemsList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="CreativeContactID" Header="Creative Contact Name" Width="90" FilterPopupMode="CheckedList" AllowEditing="True">
<dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings Name="cboCreativeContact"
DisplayMember="ContactName"
AutoComplete="True"
ValueMember="ContactID"
ItemsSource="{Binding Path=Data.CreativeAgContactList, UpdateSourceTrigger=PropertyChanged}" />
</dxg:GridColumn.EditSettings>
<dxg:GridColumn.CellStyle>
<Style TargetType="{x:Type dxg:CellContentPresenter}">
<Setter Property="Background" Value="#FFE8F2F3" />
<Setter Property="TextBlock.Foreground" Value="Black" />
</Style>
</dxg:GridColumn.CellStyle>
</dxg:GridColumn>
</dxg:GridControl.Columns>

如您所见,我的网格绑定(bind)到 ChaseListHelperClassItemsList :
public List<CreateChaseListHelperClass> ChaseListHelperClassItemsList
{
get
{
return chaseListHelperClassItemsList;
}
set
{
chaseListHelperClassItemsList = value;
OnPropertyChanged("ChaseListHelperClassItemsList");
}
}

创建ChaseListHelperClass:
    public class CreateChaseListHelperClass
{
private int creativeContactID;

public int CreativeContactID
{
get;
set;
}

public IQueryable<Contacts> CreativeAgContactList
{
get;
}
}

我的问题是,如何绑定(bind) cboCreativeContact ItemSource 到我的 CreateChaseListHelperClass 中的列表, CreativeAgContactList .

我当前的绑定(bind)如下所示:
ItemsSource="{Binding Path=Data.CreativeAgContactList, UpdateSourceTrigger=PropertyChanged}"

我的 DataContext 在我的 View 中设置:
DataContact = ChaseListViewModel

所以结构是
ChaseListViewModel-CreateChaseListHelperClassList-CreativeAgContactList

我想设置 CreateAgContactList作为 ItemSource在我的组合框上

最佳答案

我们去吧。使用单元格模板:

<dxg:GridColumn FieldName="CreativeAgContactID" Header="Creative Contact Name" Width="90" FilterPopupMode="CheckedList" AllowEditing="True">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:ComboBoxEdit Name="cboCreativeContact"
DisplayMember="ContactName"
ValueMember="ContactID"
AutoComplete="True"
EditValue="{Binding Path=ContactID, UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding Path=Data.CreativeAgContactList, UpdateSourceTrigger=PropertyChanged}">
</dxe:ComboBoxEdit>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
<dxg:GridColumn.CellStyle>
<Style TargetType="{x:Type dxg:CellContentPresenter}">
<Setter Property="Background" Value="#FFE8F2F3" />
<Setter Property="TextBlock.Foreground" Value="Black" />
</Style>
</dxg:GridColumn.CellStyle>
</dxg:GridColumn>

关于c# - 如何将列表绑定(bind)到 Data Grids 数据源的子类中的组合框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5062782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com