Hi,
I have XamDataPresenter, we are binding this XamDataPresenter with XML file and data is displaying in Tabular form, My problem is that while right click on any Row( Record), i didn't get Row(Record value), Actually my requirement is that when rigth click on any row i want row index, so i can get any column value on that bases of that index value.
Thanks,
Ajay
Hello Curtis,
I am trying to implement similler type of DataTrigger on DataPresenter in which I want to set row active depending up on data in it,
The scenaron is as follows..
I am assigning datasource to DataPresenter as follows...
(Application.Current.Resources.Add["PatientName"] ="LMN" is set in Constructor of Window)
private void LoadData() { List<string> str = new List<string>();
str.Add("ABC"); str.Add("PQR"); str.Add("LMN"); str.Add("XYZ"); str.Add("KLM");
InfraGrid.DataSource = str; }
Applied DataTrigger as follws...
<Style TargetType="{x:Type infra:DataRecordCellArea}"> <Style.Triggers> <DataTrigger Value="True"> <DataTrigger.Binding> <MultiBinding Converter="{StaticResource selectPatient}"> <Binding RelativeSource="{RelativeSource self}" Path="Record.Cells[0].Value"/> <Binding Path="Resources" Source="{x:Static Application.Current}"/> </MultiBinding> </DataTrigger.Binding> <Setter Property="IsSelected" Value="True"/> <Setter Property="IsActive" Value="True"/> </DataTrigger> </Style.Triggers> </Style>
The converter selectPatient is as follows..
public class MultiValueConverterCompareForEqual : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { System.Windows.ResourceDictionary rd = (System.Windows.ResourceDictionary)values[1]; if (rd["PatientName"] != null && rd["PatientName"].Equals(values[0])) return true; else return false;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } }}
When first time datasource get assigned to the DataPresenter,
As Application.Current.Resources.Add["PatientName"] ="LMN" is set, the third record will get select.
I have written code on record activated which sets
Application.Current.Resources.Add["PatientName"] value to the cell value. So if I will click on row with Value "ABC" , value in Application.Current.Resources.Add["PatientName"] will become "ABC".
After that If I will execute follwing code to reassign the datasource,the DataTrigger executes with call to converter but dose not select the record"ABC"....
InfraGrid.DataSource = null;
Is there any issue with the DataPresenter which not refresh the DataPresenter...?
The following XAML declaration will work. Targeting the DataRecordCellArea with the Record Cell index better ensures that the trigger will resolve itself.
<Style TargetType="{x:Type Infragistics:DataRecordCellArea}">
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.Cells[1].Value}" Value="True" >
<Setter Property="IsSelected" Value="True"/>
<Setter Property="IsActive" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
Hi Curtis,
Will you please give me your Email Id so that I will send you the sample which has the mentioned problem?
Is anybody has any idea about the reason why the above code not working?
I have a List with field as IsDefault and I assigned it as datasource to XAMDataPresenter. I want the record get selected when IsDefault field has value TRUE. (Only one record will have TRUE value)
I tried this...
<Style TargetType="{x:Type InfraXamGrid:DataRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=DataRecord.DataItem.IsDefault}" Value="true"> <Setter Property="IsSelected" Value="True"/> <Setter Property="IsActive" Value="True"/> </DataTrigger> </Style.Triggers> </Style>
Please let me know if you need more information about the problem.
The comboBox issue is different than this problem.