Click here to Skip to main content
13,259,194 members (51,013 online)
Rate this:
Please Sign up or sign in to vote.
Hi all,

I have developed a application which uses PRISM 4.0 in which i have a UserControl and a DataGrid in it. Based on the data grid cell value the IvalueConvertor Binded to the CellTemplate Below

<DataTemplate x:Key="cellContentNumberTemplate"  >
            <TextBlock Text="{Binding}" TextAlignment="Right" Tag="{Binding Path=.}" x:Name="numTextBlock"  
                       Foreground="{Binding Path=., Converter={StaticResource fontColorConvertor}, RelativeSource={RelativeSource Self}}"  />

Will use the following code to get Border (Visual Parent) of that particular TextBlock

Border templateBorder = Eagle.Windows.Helpers.UIHelpers.FindVisualParent<Border>(txt);

By using the Border i am changing the Background, BorderBrush, BorderThickness. which works

But when i suppose to scroll Datagrid the style what i have applied was changing to some other cell Virtually (The value was not actually changing but the datagrid mimicks the change).

do any one have this problem previously please let me get any solution for this.
Posted 8-Apr-13 22:43pm
Updated 8-Apr-13 22:46pm
Thomas Duwe 9-Apr-13 5:57am
I used DataTriggers in the DataTemplate in conjunction with a converter in the DataTrigger's binding to return true/false if something needed a change.
For example you can trigger the changes if the DataContext of the DataGridCell changes:
<datatrigger value="True" binding="{Binding Path=DataContext, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource AncestorType=DataGridCell, Mode=FindAncestor}, Converter={<converter here>}}" Value="True">

Whereas the converter needs to return true or false so that the binding will work.

And inside of DataTrigger you can then set the properties of "numTextBlock".
_AKA_KSN_ 9-Apr-13 6:31am
Thanks for reply,
ya i have tried. As i have mentioned above i am getting the Border which is VisualParent
of the TextBlock Which is done by the IValueConvertor with the Border object i am setting
the Background and BorderThickNess of the border.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100