Hi,
I've added a new button on the header of my tile using a ToggleButton and a CommandSource in the TilePane ControlTemplate . I can capture the event when a user clicks on the button. The question I have for you is in the event where I handle the click of the button is it possible to fire a custom animation that will apply to that specific tile?
For example, I was thinking my button would toggle an animation that would flip that tile over exposing a different data template/user control on the back for configuring settings for the control on the front... or something like this :)
public class SettingsCommand : Infragistics.Silverlight.CommandBase { public override bool CanExecute(object parameter) { return true; } public override void Execute(object parameter) {
// for example, in here... how do I know what tile I'm clicking on, so I have a way to fire the correct animation on the tile? All I seem to have here is my original command source that I can't find the tile that it was attached too in the framework element tree } }
Any ideas?
Thanks,Kevin
Hi Kevin,You can pass the tile as a parameter:<Button Content="Settings" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"> <ig:Commanding.Command> <local:AppCommandSource EventName="Click" ParameterBinding="{Binding}"/> </ig:Commanding.Command></Button>and then... it is easy:public override void Execute(object parameter){TilePane tile = this.CommandSource.ParameterResolved as TilePane;RotateTransform rt = new RotateTransform();tile.RenderTransform = rt;tile.RenderTransformOrigin = new Point(0.5, 0.5);DoubleAnimation da = new DoubleAnimation();Storyboard.SetTarget(da, rt);Storyboard.SetTargetProperty(da, new PropertyPath("Angle"));Storyboard sb = new Storyboard();sb.Duration = new Duration(TimeSpan.FromMilliseconds(1000));da.Duration = sb.Duration;sb.Children.Add(da);sb.AutoReverse = false;da.From = 0;da.To = 360;sb.Begin();}Regards,Marin
I'm trying to do the same but i have a custom usercontrol that i display as a contentcontrol in my tilepane. inside my usercontrol i have a grid that contains a list of buttons. when i click on the button i want the tile to rotate.
The above works if you're passing the templated parent, but in my example the tilepane is not the templated parent. Is there a way i can get access to the tilepane from my usercontrol?
Thanks.
Hi,As far I understand your scenario is something like this:<igTv:XamWebTileView> <igTv:TilePane Header="Tile 1"> <local:SilverlightControl1/> </igTv:TilePane></igTv:XamWebTileView>The tile pane is a parent of the user control.The following sample demonstrates how can use this in XAML.<UserControl x:Class="SilverlightApplication1.SilverlightControl1"xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:x=http://schemas.microsoft.com/winfx/2006/xamlLoaded="UserControl_Loaded"> <Grid x:Name="LayoutRoot" Background="White"> <TextBlock Text="{Binding Path=Parent.Header}"/> </Grid></UserControl>private void UserControl_Loaded(object sender, RoutedEventArgs e){ this.DataContext = this;}It just illustrates how it works, you can use the Parent property from code.Regards,Marin