Hi,
I have studied the sample of Chart Info Strips, and I do below changes to make the info strip be movable:
First, import these two dlls(Microsoft.Expression.Interactions,System.Windows.Interactivity) in IGDataChart.WPF and Infragistics.SamplesBrowser.WPF project, and then in ChartInfoStrips.xaml, I add
<i:Interaction.Behaviors> <il:MouseDragElementBehavior ConstrainToParentBounds="False" /> </i:Interaction.Behaviors>
under TextBlock.
<DataTemplate x:Key="VerticalInfoStripTemplate"> <Grid Margin="0" Width="{Binding Width}" Height="{Binding Height}"> <Rectangle Fill="{Binding Fill}" Opacity="1" /> <TextBlock HorizontalAlignment="Center" Cursor="Hand" VerticalAlignment="Center" Foreground="DimGray" FontSize="30" FontWeight="Bold" Text="{Binding Label}" RenderTransformOrigin=".5,.5"> <i:Interaction.Behaviors> <il:MouseDragElementBehavior ConstrainToParentBounds="False" /> </i:Interaction.Behaviors> <TextBlock.RenderTransform> <RotateTransform Angle="90" /> </TextBlock.RenderTransform> </TextBlock> </Grid> </DataTemplate>
Now it's movable. The requirement is when I move it to another position, I want to get the position of it, and then save the position in order that when next time I open the page, it's in the position where I move it before.
Do I make my self clearly? Waiting for your answer, thanks~~
Hello Charlie,
I can suggest you see this forum thread:
http://social.msdn.microsoft.com/Forums/silverlight/en-US/faa7c02e-3b83-41e6-b53f-00c02d6d1cc7/setting-initial-position-for-control-with-mousedragelementbehavior
from MSDN forums, where a similar question is discussed. Also if you have further questions about Interactions I can suggest you ask them I the MSDN forums, where you can get an answer from an Microsoft expert.
Hello Stefan,
Thanks for you solution. Now I can get the position, and save the position, but how can I set the position when I open the page in next time?
Hello,
Thank you for your post. I have been looking into it and I can suggest you handle the MouseDragElementBehavior’s DragFinished event and in the handler you can use the sender to get the X and Y coordinates like this:
double x = (sender as MouseDragElementBehavior).X; double y = (sender as MouseDragElementBehavior).Y;
Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.