簡體   English   中英

如何將文本編輯與devexpress WPF網格單元格值綁定?

[英]How to Bind TextEdit with devexpress WPF Grid cell Value?

我有一個網格,可以在特定列上顯示一些數據。 我想將Grid Column Value設置為DataTemplate的TextEdit並將DataTemplate綁定到Description column。怎么辦?

protected void GetAllInfills()
{
    List<Infill> infillList = new List<Infill>();
    infillList=BLL.GetAllInfills();
    if (infillList != null)
    {
        grdInfill.ItemsSource = infillList;
        grdInfill.GroupBy(grdInfill.Columns["GlassType"], ColumnSortOrder.Ascending);
        grdInfill.GroupBy(grdInfill.Columns["GlassDescription"], ColumnSortOrder.Ascending);
        grdInfill.AutoExpandAllGroups = true;
    }

}
 <Window.Resources>

        <DataTemplate x:Key="descriptionHeader">
            <Border BorderBrush="Black"  BorderThickness="1" Width="1300">
                <StackPanel Orientation="Vertical" Margin="5,5,1,5">
                    <TextBlock Name="txtdescTitle" FlowDirection="LeftToRight" VerticalAlignment="Top"  HorizontalAlignment="Left" Text="{Binding ElementName = desc, Path = DataCell}" Width="200" TextWrapping="Wrap"  /> <!--"Glass 1 description 1* INSULATED"-->
                    <StackPanel Orientation="Horizontal" Margin="5" Height="80">
                        <Image Source=".\Images\description_img.png"  Stretch="None" FlowDirection="LeftToRight" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="1"/>
                        <StackPanel Orientation="Vertical" Margin="2">
                            <TextBlock Name="txtdesc1" Margin="2" FlowDirection="LeftToRight" Text="OL:1/4' Bronze-Tempered-Solar Ban #60"  TextWrapping="Wrap"  />
                            <TextBlock Name="txtdesc2" Margin="2" FlowDirection="LeftToRight" Text="AS:1/2' Air Space with Argon"  TextWrapping="Wrap"  />
                            <TextBlock Name="txtdesc3" Margin="2" FlowDirection="LeftToRight" Text="IL:1/4' Float-Clear"  TextWrapping="Wrap"  />
                        </StackPanel>
                    </StackPanel>
                </StackPanel>

            </Border>

        </DataTemplate>
    </Window.Resources>
    <dxg:GridControl Name="grdInfill"  Height="700" VerticalAlignment="Top">
        <dxg:GridControl.Columns>

            <dxg:GridColumn FieldName="GlassType" AllowEditing="False"  />
            <dxg:GridColumn Name="desc"  FieldName="GlassDescription"   AllowEditing="False" Width="20"  GroupValueTemplate="{StaticResource descriptionHeader}"/>
            <dxg:GridColumn FieldName="GlassType" AllowEditing="False" />
            <dxg:GridColumn Name="qty" FieldName="Quantity" AllowEditing="False"  />
            <dxg:GridColumn FieldName="Width" AllowEditing="False" Header="Length"/>
            <dxg:GridColumn FieldName="Height" AllowEditing="False"/>
            <dxg:GridColumn FieldName="Elevation" AllowEditing="False"/>
 </dxg:GridControl.Columns>
  <dxg:GridControl.View>
            <dxg:TableView ShowTotalSummary="True" AutoWidth="True" DetailHeaderContent="True" ShowGroupPanel="False" ShowIndicator="False"/>
        </dxg:GridControl.View>
    </dxg:GridControl>

幫助贊賞! 謝謝!

您可以嘗試通過以下方式使用模板:

<dxg:GridColumn Name="desc"  FieldName="GlassDescription"   AllowEditing="False" Width="20">
    <dxg:GridColumn.CellTemplate>
        <DataTemplate>
            <Border ...>
            </Border>
        </DataTemplate>
    </dxg:GridColumn.CellTemplate>
</dxg:GridColumn>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM