This question is locked. New answers and comments are not allowed.
Hi I think this is probably very easy, but I can't seem to find the right method.
I have two columns in the LINQ data source, Rank and PreviousRank.
In a GridViewDataColumn I have an image, and the image needs to be either an up arrow or a down arrow depending on the change of Rank compared to PreviousRank.
So on the image loaded event I have an event, now when I am in the event, how do I access the Rank and PreviousRank of the rows data?
I could bind a value to the image right? But this is only one. I see a DataContext, can I set that so when I am in the image loaded event, I can just access the data source row and go sourcerow.Rank and sourcerow.PreviousRank?
Does this make sense?
| <telerikGridView:RadGridView |
| x:Name="RadGrid8020" |
| MinWidth="400" MaxWidth="900" |
| ShowGroupPanel="false" |
| CanUserDeleteRows="false" |
| CanUserFreezeColumns="false" |
| CanUserInsertRows="false" |
| CanUserReorderColumns="true" |
| CanUserResizeColumns="false" |
| CanUserSelect="true" |
| CanUserSortColumns="true" |
| IsReadOnly="true" |
| AutoGenerateColumns="false" ScrollMode="RealTime" |
| > |
| <telerikGridView:RadGridView.SortDescriptors> |
| <telerikData:SortDescriptor Member="Rank" SortDirection="Ascending" /> |
| </telerikGridView:RadGridView.SortDescriptors> |
| <telerikGridView:RadGridView.GroupHeaderTemplate> |
| <DataTemplate> |
| <TextBlock Foreground="Green" Text="" Loaded="RadGrid8020_TextBlock_Loaded"/> |
| </DataTemplate> |
| </telerikGridView:RadGridView.GroupHeaderTemplate> |
| <telerikGridView:RadGridView.Columns> |
| <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Rank}" Header="Rank" IsFilterable="false" IsSortable="true"> |
| <telerikGridView:GridViewDataColumn.CellTemplate> |
| <DataTemplate> |
| <StackPanel Orientation="Horizontal"> <!--HERE IS THE IMAGE!!!--> |
| <Image Loaded="RadGrid8020_RankMoveImage_Loaded"/><TextBlock Text="{Binding Rank}"/> |
| </StackPanel> |
| </DataTemplate> |
| </telerikGridView:GridViewDataColumn.CellTemplate> |
| </telerikGridView:GridViewDataColumn> |
| <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding CustomerName}" Header="Client" HeaderTextAlignment="Left" IsFilterable="false" IsSortable="true" TextAlignment="Left" /> |
| <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding JobCount}" Header="Job Count" HeaderTextAlignment="Right" IsFilterable="false" IsSortable="true" TextAlignment="Right" DataFormatString="{}{0:n0}" /> |
| <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Turnover}" Header="Turnover" HeaderTextAlignment="Right" IsFilterable="false" IsSortable="true" TextAlignment="Right" DataFormatString="{}{0:c2}" /> |
| <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding AverageJobTurnover}" Header="Avg Per Job" HeaderTextAlignment="Right" IsFilterable="false" TextAlignment="Right" DataFormatString="{}{0:c2}" /> |
| </telerikGridView:RadGridView.Columns> |
| </telerikGridView:RadGridView> |
| private void RadGrid8020_RankMoveImage_Loaded(object sender, RoutedEventArgs e) |
| { |
| //================================== |
| //Need to say |
| // IF rowdata.RANK < rowdata.PREVIOUSRANK then img = uparrow |
| // ELSE img = downarrow |
| //================================== |
| string imgfile = "iconarrowup.png"; |
| //string imgfile = "iconarrowdown.png"; |
| StreamResourceInfo sr = Application.GetResourceStream(new Uri("ewreportingapp;component/Resources/" + imgfile, UriKind.Relative)); |
| BitmapImage bmp = new BitmapImage(); |
| bmp.SetSource(sr.Stream); |
| Image img = (Image)sender; |
| img.Source = bmp; |
| } |
