WOW really made me think :), but I believe I found a workaround that you can use. You will need a converter, but this is the only code you need in C # - the rest is in pure XAML.
I restored some XAML based on your input:
<Grid VerticalAlignment="Center" HorizontalAlignment="Left" Background="Lime" x:Name="m_Grid"> <Grid.RenderTransform> <CompositeTransform TranslateX="{Binding ActualWidth, Converter={StaticResource InverseTranslateXConverter}, ElementName=m_Grid}" /> </Grid.RenderTransform> <Button x:Name="m_Button" Margin="50" Content="Hello World" /> </Grid>
So I'm really really just to wrap the slider inside the grid and set the TranslateX property to ActualWidth of the content * -1 (done using the converter):
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { double d = 0; if (double.TryParse(value.ToString(), out d)) { return d * -1; } return value; }
To show it (paste), I use simple animation:
<UserControl.Resources> <Storyboard x:Name="Storyboard1"> <DoubleAnimation x:Name="m_Animation" Duration="0:0:0.2" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="m_Grid" d:IsOptimized="True" /> </Storyboard>
This is not very, but it works :)
[EDIT] Just deleted outergrid - it was impenetrable.
thomasmartinsen
source share