Hello,
So far i have been reading a lot about WPF in a short time and can't solve some problems. Hope you guys cand clear the air for me.
1) I'm looking to implement some animations for the xamdatagrid rows. What i need is to create something like what the carousel does, expand the size of a row when i drag the mouse over it (i need a scaling effect on my datarow). Is that possible? And if yes, can that be done to a cell or any sort of control/component ? How?
2) Can a datagrid cell contain a panel or any sort of container that holds another custom usercontrol, like the carouselPanel? (i know it may seem stupid...but it may work, in classic infra with a little creation filter rewriting you could do just about anything :D )
3) If there is an accessible function just like CreationFilter, is there any way to get some sort of support for rewriting it, so that we may modify WPF controls?
4) I see here valuelists are not so popular, do you recomand not using them?
Thank you, I hope someone can answer nr 1 and 2 since they are a more pressing matter.
1. Regarding the Scaling Effects. If you want to scale a records, you can create a style for the DataRecordPresenter and scale it. Something like this:
<Style TargetType="{x:Type igDP:DataRecordPresenter}"><Setter Property="RenderTransformOrigin" Value="0,0.5"/><Setter.Value><ScaleTransform ScaleX="1" ScaleY="1"/></Setter.Value></Setter><EventSetter Event="MouseEnter" Handler="dp_MouseEnter"/><EventSetter Event="MouseLeave" Handler="dp_MouseLeave"/></Style>
void dp_MouseLeave(object sender, MouseEventArgs e)
{
if (sender != null)
DataRecordPresenter dp = sender as DataRecordPresenter;
dp.RenderTransform = new ScaleTransform(1, 1);
}
void dp_MouseEnter(object sender, MouseEventArgs e)
dp.RenderTransform = new ScaleTransform(1.2, 1.2);
You can do it on any element. If you want on a Cell, the target type should be CellValuePresenter. You can do the same for the other parts of the XamDataGrid - LabelPresenter, RecordSelector, ExpansionIndicator,etc.
Moreover, you can take a look at the default styles for our controls/parts in the DefaultStyles directory in the Infragistics folder on your computer. This also concerns your second question - yes, the CellValuePresenter can hold any element as its content property is of type object. All you have to do is retemplate it using these default styles as a basis for your own. You might find useful looking at this post by Andrew Smith about hosting elements in the XamDataGrid.
In the case of hosting complex elements in a Cell, you should be aware of the nesting element depth limitation of the WPF framework (I believe around 255).
I am not quite sure what you mean by CreationFilter, so please give us more information about that.
4) We recommend using collections that support two-way binding like ObservableCollection<T> or BindingList<T> which are most commonly used with the XamDataGrid. Of course, you can use any collection,list that you want.
Hope this helps
hello,
thank you for you reply, that helps a lot.
in the past i was working with the 2 functiions, BeforeCreateChildElements and AfterCreateChildElements. I would then modify any UIElement and place other elements into it. Like say putting a custom button in the header of an ultratab and so on.
ok, so i tried that code:
<igDP:XamDataPresenter x:Name="dg">
<igDP:XamDataPresenter.Resources>
<Style x:Key="mama" TargetType="{x:Type igDP:DataRecordPresenter}">
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="1" ScaleY="1"/>
</Setter.Value>
</Setter>
<EventSetter Event="MouseEnter" Handler="dp_MouseEnter"/>
<EventSetter Event="MouseLeave" Handler="dp_MouseLeave"/>
</Style>
</igDP:XamDataPresenter.Resources>
<igDP:XamDataPresenter.FieldLayoutSettings>
<igDP:FieldLayoutSettings RecordListControlStyle="{StaticResource mama}"/>
</igDP:XamDataPresenter.FieldLayoutSettings>
</igDP:XamDataPresenter>
but it does not work, the events will not trigger (They are written in my .cs file, no reason to post them here).
please tell me if I am doing something wrong as I am new in all this xaml.
Again, thanks a lot!
The problem is the way you set the style. You should set that style to the DataRecordPresenterStyle property of the FieldLayoutSettings object. If you do not set x:key value of the style, it will be applied automatically.
thank you for your indications, it works just fine!
here's the code for getting the cellvaluepersenter on any mouse event
void xamDataGrid1_PreviewMouseMove(object sender, MouseEventArgs e)
DependencyObject dep = (DependencyObject)e.OriginalSource;
try
Infragistics.Windows.DataPresenter.DataRecordPresenter caca = Infragistics.Windows.Utilities.GetAncestorFromType(dep, typeof(Infragistics.Windows.DataPresenter.DataRecordPresenter), true) as Infragistics.Windows.DataPresenter.DataRecordPresenter;
//gets the row
Infragistics.Windows.DataPresenter.CellValuePresenter cell = Infragistics.Windows.Utilities.GetAncestorFromType(dep, typeof(Infragistics.Windows.DataPresenter.CellValuePresenter), true) as Infragistics.Windows.DataPresenter.CellValuePresenter;
// gets the cell, do whatever you want with it now
catch
Yes,
you can use our helper methods Infragistics.Windows.GetAncestorFromType/Name, Infragistics.Windows.GetDescendantFromType/Name.
The type would be CellValuePresenter, and the object you pass in as parent/child is the e.OriginalSource
yes, thank you, i managed to solve it.
i am now trying to retrieve the cell over which the mouse is on the previewmousemove event.
is it that simple as casting the e.originalsource to a cell type?