Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WPF .NET4 PRISM .NET4.5
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}}"  />
        </DataTemplate>
 
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
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 8-Apr-13 22:43pm
(unknown member)
Edited 8-Apr-13 22:46pm
v2
Comments
Thomas Duwe at 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".
_AKA_KSN_ at 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
0 OriginalGriff 515
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 209
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2014
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