C# 绑定Datagrid列WPF时调用方法
在我的asp.net GridView中,我使用以下方式转换GridView列数据C# 绑定Datagrid列WPF时调用方法,c#,wpf,c#-4.0,wpfdatagrid,C#,Wpf,C# 4.0,Wpfdatagrid,在我的asp.net GridView中,我使用以下方式转换GridView列数据 <ItemTemplate> <asp:Label ID="lb_gvInbox_DelTime" runat="server" Text='<%# this.GetTimeFormat(Eval("Order_Date"))%>'/> </ItemTemplate> 在WPF DataGrid中,我如何做到这一点???您正在寻找的是 类DateForm
<ItemTemplate>
<asp:Label ID="lb_gvInbox_DelTime" runat="server" Text='<%# this.GetTimeFormat(Eval("Order_Date"))%>'/>
</ItemTemplate>
在WPF DataGrid中,我如何做到这一点???您正在寻找的是
类DateFormatter:IValueConverter
{
公共对象转换(对象值、类型targetType、对象参数、CultureInfo区域性)
{
//你的代码
}
}
您正在寻找的是
类DateFormatter:IValueConverter
{
公共对象转换(对象值、类型targetType、对象参数、CultureInfo区域性)
{
//你的代码
}
}
protected string GetTimeFormat(object dateTimeObj)
{
DateTime dateTime = (DateTime)dateTimeObj;
return (dateTime.Date == time.Date) ? dateTime.ToString("hh:mm tt", CultureInfo.InvariantCulture)
: (dateTime.Year == time.Year) ? dateTime.ToString("MMM dd") : dateTime.ToString("dd/MMM/yy");
}
<TextBlock Text="{Binding Order_Date, Converter={StaticResource DateFormatter}}" />
class DateFormatter: IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
// your code
}
}