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 Ajay,
Usually a right-click will invoke a contextual menu when implemented. Do your requirements specify a contextual menu of a list of indices appearing? If not, please clarify what you would like to accomplish.
Curtis
Hello Curtis,
We want to select context menu at run time depending upon type of the record on which the Mouse rightClick event occured . i.e. if there are two levels of records in the Datapresenter e.g. First row contains Order and rows following to it contains Products in the Order.
I have 2 Context Menus, one for Orders and second for Products.
Suppose when I right click on Order Record (Row) then I need to show the context menu for Orders and when I Right Click on any of the Product record which belongs to any of the Order record then I need to show context menu for Products.
The problem which we are facing is that before right clicking on any record, we are supposed to first left click on it , make it as Activerecord and the we need to right click on it so that we can identify the records (whether it is order record or product record ) at runtime and decide which context menu we should show Up.
Here is some code for Right Click event
private void DataPresenter_MouseRightButtonDown(object sender, MouseButtonEventArgs e) {
DataRecord drCurrent = (DataRecord)DataPresenter.ActiveRecord;
if(drCurrent.Cells[0].Value =="Product")
DataPresenter.ContextMenu = ProductContextMenu;
else
DataPresenter.ContextMenu = OrderContextMenu;
}
The expected behaviour is that when we RightClick on any record of Datapresenter, the record should become Activerecord of the Datapresenter (instead of first left click on the record, make it activeRedord and then Right click on the same record).
Please let us know whether we are missing any event of Datapresenter which provides expected functionality.
Chetan Deshmukh
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...?
Hi Curtis,
Is there any Property or event of XamDataPresenter which can give me record on which currently MouseOver happened..? i.e. I want to implement ToolTip like functionality and I want Currnet DataRerord on whcih user has his mouse.
Hello Chetan,
The best way to get what you want is to assign a MouseEnter event handler to the XamDataGrid and then use the VisualTreeHelper.HitTest method to figure out which field if any the mouse is over. In this same post further up someone posted some sample code which illustrates how to use HitTest. I have not tested this code, you can find the code in this same forum here:http://community.infragistics.com/forums/p/5985/29501.aspx#29501
A simpler solution would be to assign the MouseEnter directly to the control that the cell uses to present its data. You can assign the MouseEnter event handler to the XamTextEditor (for example) in a CellValuePresenter style. Then you can affect the control directly (depending on what you want to do in the MouseEnter event).
Let us know if you need more help with this.
I am facing one more issue with Infragistics Grid which is as follows:
My datasource is a list of a class which has a field of type "RecordType". I have overrided the ToString method of "RecordType" class so that when I bind the List of the class, I can see Record Type of each record in the Grid in "Record Type" column.
The problem is that this column is not sortable eventhough RecordType.ToString() returns "Name" Property of the RecordType object which is a String.
I tried to assign a CellValuePresenterStyle to a UnboundField with Label "Record Type" but it shows only arror on the FieldHeader which shows sorting direction but not sorting the contents. This might be because in CellValuePresenter I used Label control to Bind the data (DataItem.RecordType.Name).
Is there any other way to show such type of data in column with Sorting working as I can not change the schema of the class or "RecordType" Class?
Please let me know if you need more details about the problem.
You may need to explicitly set the type to string in the Field Settings. If you could replicate the issue in a smaller sample project, I could better determine why sorting isn't working and correct the problem.
Thank you!
Hi Custis,
As we discussed, sharing the solution of the problem mentioned above by me..
Problem inshort: When we bind any object(which is not a string) to DataGrid field, the field not remains sortable.
Solution: Create an UnBound Field and set Binding to it as follows.
<InfraGrid:UnboundField BindingPath="[ObjectName].[PropertyName]" Label="Preferred Description" Width="480">
In my case I had a Colloection as a datasource. The collection was of class which has a field of type RecordType. When I bind the colloection to a DataGrid, RecordType field gets assigned to one of the fields. As I override ToString method of RecordType class and returned RecordName, I could see the RecordNames in the field but cound not sort the field. When I used Unbound field and explicitely set the BindingPath to the RecordName, I cound see the RecordNames in the field as well as could sort the field.
I received your sample. I will get back to you as soon as I determine what the problem is and will communicate the solution here for other users as well.
I tried following but not working.
EditAsType="{x:Type Sys:String}" on FieldSettings
can I try anything else to solve the issue?
Sent you an email with the sample application attached.
Please let me know if you need more details about the issue.
Chetan