Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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


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

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


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

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
Updated 8-Apr-13 21:46pm
v2
Comments
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">
</datatrigger>

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".
[no name] 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900