Datagrid列定义silverlight问题

时间:2011-01-28 21:21:41

标签: silverlight xaml datagrid datagridview

xaml中的

  

错误1类型'DataGridTextColumn'   不支持直接

我想在datagridview的列中的每一行中添加一个按钮 在数据网格中

查找

<UserControl x:Class="Paradigma.Silverlight.DiccionarioDatos.UserControlAdminEmpleados"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:ig="http://schemas.infragistics.com/xaml"
    mc:Ignorable="d"
    d:DesignHeight="469" d:DesignWidth="641" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">

    <Grid x:Name="LayoutRoot" Background="White">
        <ListBox Height="145" HorizontalAlignment="Left" Margin="12,32,0,0" Name="lbEmpleado" VerticalAlignment="Top" Width="267" />
        <ListBox Height="145" HorizontalAlignment="Right" Margin="0,32,100,0" Name="lbRoles" VerticalAlignment="Top" Width="256" />
        <Button Content="Agregar" Margin="0,32,11,0" Name="butAgregar" Click="butAgregar_Click" HorizontalAlignment="Right" Width="83" Height="145" VerticalAlignment="Top" />
        <sdk:DataGrid AutoGenerateColumns="False" Height="230" Margin="11,0,11,47" Name="dgRelaciones" VerticalAlignment="Bottom">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Empleado" IsReadOnly="False" Width="Auto" Binding="{Binding Empleado.Nombre}"/>
                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Rol" IsReadOnly="False" Width="Auto" Binding="{Binding Rol.Nombre}"/>
                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Acciones" IsReadOnly="False" Width="Auto" >
                    <StackPanel />

                </sdk:DataGridTextColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
    </Grid>
</UserControl>

1 个答案:

答案 0 :(得分:2)

我使用的是sdk:DataGridTextColumn,而不是sdk:DataGridTemplateColumn:S

<sdk:DataGrid AutoGenerateColumns="False" Height="230" Margin="11,0,11,47" Name="dgRelaciones" VerticalAlignment="Bottom">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Empleado" IsReadOnly="False" Width="Auto" Binding="{Binding Empleado.Nombre}"/>
                <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Rol" IsReadOnly="False" Width="Auto" Binding="{Binding Rol.Nombre}"/>
                <sdk:DataGridTemplateColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Acciones" IsReadOnly="False" Width="Auto" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <!--ELEMENTS HERE-->
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>

它有效