当前位置:网站首页 / WPF / 正文

【ay wpf markup】AY XAML应该这样玩-写个复杂的颜色环【13/18】

时间:2016年07月22日 | 作者 : aaronyang | 分类 : WPF | 浏览: 1257次 | 评论 0

<Canvas x:Name="LayoutRoot">
        <Canvas.Resources>
            <p:ResourceCollection x:Key="Brushes">
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <GradientStop Color="Red" Offset="0"/>
                    <GradientStop Color="Yellow" Offset="0.5"/>
                    <GradientStop Color="Blue" Offset="1"/>
                </LinearGradientBrush>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <GradientStop Color="Blue" Offset="0"/>
                    <GradientStop Color="Green" Offset="0.5"/>
                    <GradientStop Color="Red" Offset="1"/>
                </LinearGradientBrush>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <GradientStop Color="Red" Offset="0"/>
                    <GradientStop Color="Yellow" Offset="0.5"/>
                    <GradientStop Color="Blue" Offset="1"/>
                </LinearGradientBrush>
                <LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
                    <GradientStop Color="Blue" Offset="0"/>
                    <GradientStop Color="Green" Offset="0.5"/>
                    <GradientStop Color="Red" Offset="1"/>
                </LinearGradientBrush>
            </p:ResourceCollection>
            <p:ResourceObject x:Key="ViewModel">
                <p:Property PropertyName="LogoData">
                    <p:Block>
                        <p:Set Var="$angle" ValuePath="-90.0"/>
                        <p:Return>
                            <p:Iterator>
                                <p:ForEach Var="$brush" Value="{StaticResource Brushes}">
                                    <p:Yield>
                                        <p:Object>
                                            <p:Property PropertyName="Angle" Path="$angle += 90"/>
                                            <p:Property PropertyName="Brush" Path="$brush"/>
                                        </p:Object>
                                    </p:Yield>
                                </p:ForEach>
                            </p:Iterator>
                        </p:Return>
                    </p:Block>
                </p:Property>
            </p:ResourceObject>
        </Canvas.Resources>
        <ItemsControl ItemsSource="{Binding Value.LogoData, Source={StaticResource ViewModel}}">
            <ItemsControl.OpacityMask>
                <RadialGradientBrush>
                    <GradientStop Color="Transparent" Offset="0.95"/>
                    <GradientStop Color="White" Offset="0.949"/>
                    <GradientStop Color="White" Offset="0.501"/>
                    <GradientStop Color="Transparent" Offset="0.5"/>
                </RadialGradientBrush>
            </ItemsControl.OpacityMask>
            <ItemsControl.Template>
                <ControlTemplate TargetType="ItemsControl">
                    <ItemsPresenter/>
                </ControlTemplate>
            </ItemsControl.Template>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Canvas/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Canvas Width="1" Height="1">
                        <Canvas.RenderTransform>
                            <RotateTransform
                                Angle="{Binding Angle}" CenterX="145" CenterY="145"/>
                        </Canvas.RenderTransform>
                        <Viewport3D Width="290" Height="290">
                            <ModelVisual3D>
                                <ModelVisual3D.Content>
                                    <Model3DGroup>
                                        <GeometryModel3D>
                                            <GeometryModel3D.Geometry>
                                                <MeshGeometry3D
                                                    Positions="0 0 0, 0 1 0, 1 0 0, 1 1 0"
                                                    TextureCoordinates="0 1, 0 0, 1 1, 1 0"
                                                    TriangleIndices="0 2 1, 2 3 1"/>
                                            </GeometryModel3D.Geometry>
                                            <GeometryModel3D.Material>
                                                <DiffuseMaterial Brush="{Binding Brush}"/>
                                            </GeometryModel3D.Material>
                                            <GeometryModel3D.Transform>
                                                <MatrixTransform3D>
                                                    <MatrixTransform3D.Matrix>
                                                        0.002,0,0,0,-0.499,-0.498,0,-0.998,
                                                        0,0,1,0,0.499,0.5,0,1
                                                    </MatrixTransform3D.Matrix>
                                                </MatrixTransform3D>
                                            </GeometryModel3D.Transform>
                                        </GeometryModel3D>
                                        <AmbientLight Color="White" />
                                    </Model3DGroup>
                                </ModelVisual3D.Content>
                            </ModelVisual3D>
                            <Viewport3D.Camera>
                                <OrthographicCamera
                                    Position="0.5 0.5 1"
                                    LookDirection="0 0 -1"
                                    UpDirection="0 1 0"
                                    Width="1"/>
                            </Viewport3D.Camera>
                        </Viewport3D>
                    </Canvas>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </Canvas>


效果图:


blob.png



====================www.ayjs.net       杨洋    wpfui.com        ayui      ay  aaronyang=======请不要转载谢谢了。=========




推荐您阅读更多有关于“WPF4.5,”的文章

猜你喜欢

额 本文暂时没人评论 来添加一个吧

发表评论

必填

选填

选填

必填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

  查看权限

合肥科大智能常年招聘C# .NET CORE,vue前端,JAVA开发,有想换工作的私聊我AY唯一QQ:875556003和AY交流

抖音号:wpfui 工作是wpf,不接活,目前主要折腾maui

AYUI8社区版Github地址:前往获取

杨洋(AaronYang简称AY,安徽六安人)目前是个人,还没公司AY唯一QQ:875556003和AY交流

高中学历,2010年开始web开发,2015年1月17日开始,兴趣学习研究WPF

声明:AYUI7个人与商用免费,源码可购买。部分DEMO不免费.AY主要靠卖技术服务挣钱

不是从我处购买的ayui7源码,我不提供任何技术服务,如果你举报从哪里买的,我可以帮你转正为我的客户,并送demo

查看捐赠

AYUI7.X MVC教程 更新如下:

第一课 第二课 程序加密教程

vs2015 企业版密钥HM6NR-QXX7C-DFW2Y-8B82K-WTYJV

vs2017 企业版密钥NJVYC-BMHX2-G77MM-4XJMR-6Q8QF

标签列表