Silverlight4Beta之CompositeTransform
Silverlight中的Transform相信大家已經(jīng)很熟悉了,它們有ScaleTransform, SkewTransform, RotateTransform和TranslateTransform
當(dāng)我們要做一些有趣的效果時(shí),這些Transform聯(lián)合起來(lái)應(yīng)用也挺叫人頭疼的,看著那么一大長(zhǎng)傳的xaml總是令人不爽。
而Silverlight4Beta中引入的CompositeTransform則解決了這個(gè)問(wèn)題
看一下類(lèi)圖
接下來(lái)做個(gè)例子,只有xaml哦
<UserControl x:Class="SilverlightApplication3.MainPage"?
??? xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"?
??? xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"?
??? xmlns:d="http://schemas.microsoft.com/expression/blend/2008"?
??? xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"?
??? mc:Ignorable="d"?
??? d:DesignHeight="300" d:DesignWidth="400">?
??? <UserControl.Resources>?
??????? <Style? TargetType="Slider">?
??????????? <Setter Property="Width" Value="200"/>?
??????? </Style>?
??? </UserControl.Resources>?
??? <Grid x:Name="LayoutRoot" Width="210">?
??????? <StackPanel x:Name="ContentStackPanel">?
??????????? <Image Source="http://www.bbniu.com/core/avatar.php?uid=77&size=middle"?Width="120" Height="120">?
??????????????? <Image.RenderTransform>?
??????????????????? <CompositeTransform x:Name="cr1"/>?
??????????????? </Image.RenderTransform>?
??????????? </Image>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="CenterX"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=CenterX,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="CenterY"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=CenterY,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="Rotation"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=Rotation,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="ScaleX"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=ScaleX,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="ScaleY"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=ScaleY,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="TranslateX"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=TranslateX,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????????? <StackPanel Orientation="Horizontal">?
??????????????? <TextBlock Text="TranslateY"/>?
??????????????? <Slider Value="{Binding ElementName=cr1,Path=TranslateY,Mode=TwoWay}"/>?
??????????? </StackPanel>?
??????? </StackPanel>?
??? </Grid>?
</UserControl>
相關(guān)的Transform只要那加粗的三行代碼就可實(shí)現(xiàn),是不是很方便呢?
?
F5運(yùn)行后的效果如圖
在線示例:http://www.bbniu.com/matrix/ShowApplication.aspx?id=28(感謝棒棒牛bbniu.com論壇)
ok.have fun~
本文轉(zhuǎn)自紫色永恒51CTO博客,原文鏈接:http://www.cnblogs.com/024hi/archive/2009/12/12/1622723.html?,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的Silverlight4Beta之CompositeTransform的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

- 上一篇: 恒科跳涨5.4%!南向资金持续买入,前景
- 下一篇: 使用YCSB检测MongoDB