Click here to Skip to main content
15,878,814 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF Multiple Projects Resource Dictionary Pin
Jammer10-Jan-09 5:54
Jammer10-Jan-09 5:54 
GeneralRe: WPF Multiple Projects Resource Dictionary Pin
Bex_300012-Jan-09 0:12
Bex_300012-Jan-09 0:12 
GeneralRe: WPF Multiple Projects Resource Dictionary Pin
Jammer12-Jan-09 22:42
Jammer12-Jan-09 22:42 
GeneralRe: WPF Multiple Projects Resource Dictionary Pin
Bex_300012-Jan-09 23:47
Bex_300012-Jan-09 23:47 
GeneralRe: WPF Multiple Projects Resource Dictionary Pin
Jammer13-Jan-09 10:12
Jammer13-Jan-09 10:12 
QuestionMove a 3D object on screen. Pin
ParagGupta9-Jan-09 2:07
ParagGupta9-Jan-09 2:07 
QuestionTo format date in datagrid column in silverlight Pin
priyagee9-Jan-09 1:02
priyagee9-Jan-09 1:02 
AnswerRe: To format date in datagrid column in silverlight Pin
johnsontroye9-Jan-09 17:22
johnsontroye9-Jan-09 17:22 
If you are binding to collection of custom objects such as Person and that class has a property such as BirthDate you could do the following:

First, create DateTimeConverter class as such:

Imports System.Windows.Data

Public Class DateTimeConverter
Implements IValueConverter

Public Function Convert(ByVal value As Object, _
ByVal targetType As System.Type, _
ByVal parameter As Object, _
ByVal culture As System.Globalization.CultureInfo) As Object _
Implements System.Windows.Data.IValueConverter.Convert

Dim DateValue As DateTime = value
Return DateValue.ToShortDateString()

End Function


Public Function ConvertBack(ByVal value As Object, _
ByVal targetType As System.Type, _
ByVal parameter As Object, _
ByVal culture As System.Globalization.CultureInfo) As Object _
Implements System.Windows.Data.IValueConverter.ConvertBack

Dim StrValue As String = value.ToString()
Dim ResultDateTime As DateTime

If DateTime.TryParse(StrValue, ResultDateTime) Then
Return ResultDateTime
End If

Return value

End Function

End Class


Next, add xmlns to to your projects namespace so you can get reference to your new class such as:
xmlns:local="clr-namespace:Silverlight_DataGrid"


Next, depending on what type of control you are using to bind to, add reference to your converter for date column. In this case, I have single column in grid, which is bound to DataGridTextColumn. The property in my class i'm binding to is BirthDate.

<data:DataGrid x:Name="myDataGrid" Grid.Row="1"
AlternatingRowBackground="AliceBlue"
Background="WhiteSmoke"
BorderBrush="DarkBlue" BorderThickness="2"
CanUserResizeColumns="True"
CanUserSortColumns="True"
Opacity="8"
AutoGenerateColumns="False">

<data:DataGrid.Columns>

<data:DataGridTextColumn Binding="{Binding BirthDate, Converter={StaticResource DateConverter}}" />

</data:DataGrid.Columns>


</data:DataGrid>


GeneralRe: To format date in datagrid column in silverlight Pin
priyagee11-Jan-09 20:11
priyagee11-Jan-09 20:11 
QuestionNeeded sample Program Which run on both windows and web. Pin
vinethgentle8-Jan-09 23:51
vinethgentle8-Jan-09 23:51 
AnswerRe: Needed sample Program Which run on both windows and web. Pin
Pete O'Hanlon9-Jan-09 1:20
mvePete O'Hanlon9-Jan-09 1:20 
QuestionGridSplitter Cursor Pin
Johan Lombaard8-Jan-09 22:27
Johan Lombaard8-Jan-09 22:27 
AnswerRe: GridSplitter Cursor Pin
User 27100910-Jan-09 15:15
User 27100910-Jan-09 15:15 
QuestionRe: GridSplitter Cursor Pin
bootis12-Aug-10 23:21
bootis12-Aug-10 23:21 
AnswerRe: GridSplitter Cursor Pin
mocasu8-Sep-10 6:16
mocasu8-Sep-10 6:16 
AnswerRe: GridSplitter Cursor Pin
schiebel-t3-Feb-09 1:50
schiebel-t3-Feb-09 1:50 
GeneralRe: GridSplitter Cursor Pin
xsumo16-Mar-10 11:49
xsumo16-Mar-10 11:49 
QuestionUnknown Error Pin
Vimalsoft(Pty) Ltd8-Jan-09 18:56
professionalVimalsoft(Pty) Ltd8-Jan-09 18:56 
AnswerRe: Unknown Error Pin
Mohammad Dayyan19-Jan-09 17:49
Mohammad Dayyan19-Jan-09 17:49 
GeneralRe: Unknown Error Pin
Vimalsoft(Pty) Ltd19-Jan-09 22:38
professionalVimalsoft(Pty) Ltd19-Jan-09 22:38 
GeneralRe: Unknown Error Pin
Mohammad Dayyan20-Jan-09 9:27
Mohammad Dayyan20-Jan-09 9:27 
GeneralRe: Unknown Error Pin
Vimalsoft(Pty) Ltd20-Jan-09 19:26
professionalVimalsoft(Pty) Ltd20-Jan-09 19:26 
GeneralRe: Unknown Error Pin
Mohammad Dayyan20-Jan-09 19:44
Mohammad Dayyan20-Jan-09 19:44 
GeneralRe: Unknown Error Pin
Vimalsoft(Pty) Ltd20-Jan-09 19:48
professionalVimalsoft(Pty) Ltd20-Jan-09 19:48 
GeneralRe: Unknown Error Pin
Mohammad Dayyan20-Jan-09 19:55
Mohammad Dayyan20-Jan-09 19:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.