Listview(WPF)上的绑定日期时间类型

时间:2009-02-09 16:59:10

标签: wpf listview binding

您好我在使用C#3.5,这可能吗?

<EditItemTemplate>
                                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("date", "{dd/MM/YYYY}")  %>'></asp:TextBox></EditItemTemplate>
                                    <ItemTemplate>

我在尝试:

<ListView Margin="0,80,0,38" Name="dlstInformes" Grid.ColumnSpan="2" >
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Numero Informe"   DisplayMemberBinding="{Binding Path= numeroinforme}" >
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock >

                                </TextBlock>   
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Nombre" DisplayMemberBinding="{Binding Path= nombreinforme}" />
                    <GridViewColumn Header="Fecha Informe" DisplayMemberBinding="{Binding Path= fechainforme}" />
                </GridView>
            </ListView.View>

1 个答案:

答案 0 :(得分:6)

这里有一个解决方案:

<ListView Margin="0,80,0,38" Name="dlstInformes" MouseDoubleClick="dlstInformes_MouseDoubleClick">
        <ListView.View>
            <GridView>
                <GridViewColumn Header="Numero Informe"   DisplayMemberBinding="{Binding Path= numeroinforme}" >

                </GridViewColumn>
                <GridViewColumn Header="Nombre" DisplayMemberBinding="{Binding Path= nombreinforme}" />
                <GridViewColumn Header="Fecha Informe">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock>
                            <TextBlock.Text>
                             <Binding Path="fechainforme" StringFormat="{}{0:MM/dd/yyyy}"/>
                             </TextBlock.Text>
                            </TextBlock>
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn> 

            </GridView>
        </ListView.View>

    </ListView>

希望有所帮助...