XAML Icon as DynamicResource

2 posts, 0 answers
  1. Harald
    Harald avatar
    48 posts
    Member since:
    Oct 2013

    Posted 06 Nov Link to this post

    <Viewbox x:Key="organization">
            <Grid Width="128" Height="128" Visibility="Visible">
                <Path Data="M28,26C26.896999,26 26,26.896999 26,28 26,29.103001 26.896999,30 28,30 29.103001,30 30,29.103001 30,28 30,26.896999 29.103001,26 28,26z M16,26C14.897,26 14,26.896999 14,28 14,29.103001 14.897,30 16,30 17.103,30 18,29.103001 18,28 18,26.896999 17.103,26 16,26z M4,26C2.8969998,26 2,26.896999 2,28 2,29.103001 2.8969998,30 4,30 5.1029999,30 6,29.103001 6,28 6,26.896999 5.1029999,26 4,26z M28,24C30.205999,24 32,25.794001 32,28 32,30.205999 30.205999,32 28,32 25.794001,32 24,30.205999 24,28 24,25.794001 25.794001,24 28,24z M16,24C18.206,24 20,25.794001 20,28 20,30.205999 18.206,32 16,32 13.794,32 12,30.205999 12,28 12,25.794001 13.794,24 16,24z M4,24C6.2060001,24 8,25.794001 8,28 8,30.205999 6.2060001,32 4,32 1.7940001,32 0,30.205999 0,28 0,25.794001 1.7940001,24 4,24z M4.5,15.053021L27.5,15.053021C28.327,15.053021,29,15.72602,29,16.553017L29,23 27,23 27,17.053017 17,17.053017 17,23.000999 15,23.000999 15,17.053017 5,17.053017 5,23 3,23 3,16.553017C3,15.72602,3.6729999,15.053021,4.5,15.053021z M11,2L11,8 21,8 21,2z M10.5,0L21.5,0C22.326996,0,23,0.67297363,23,1.5L23,8.5C23,9.3270264,22.326996,10,21.5,10L17,10 17,14.032018 15,14.032018 15,10 10.5,10C9.6730042,10,9,9.3270264,9,8.5L9,1.5C9,0.67297363,9.6730042,0,10.5,0z" Stretch="Uniform" Fill="#FF235598" Width="98" Height="98" Margin="0,0,0,0" RenderTransformOrigin="0.5,0.5">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <TransformGroup.Children>
                                <RotateTransform Angle="0" />
                                <ScaleTransform ScaleX="1" ScaleY="1" />
                            </TransformGroup.Children>
                        </TransformGroup>
                    </Path.RenderTransform>
                </Path>
            </Grid>
        </Viewbox>

     

    I have icons that are available as XAML code (Viewbox). I would like to add a XAML Icon to the button. The following code works:

     

    <telerik:RadButton Height="250" Width="250" Content="{DynamicResource organization}"/>

     

    This code does not work:

    <telerik:RadRibbonButton x:Name="btnShowDashbord" Content="Home" LargeImage="{DynamicResource organization}" Size="Large" />

     

    How can I include an XAML icon as ImageSource?

     

     

  2. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 09 Nov Link to this post

    Hi Harald,

    The LargeImage property of RadRibbonButton is of type ImageSource, thus you cannot set it to a UIElement object.

    To achieve the desired goal, you can use an image or set the path to the button's content as in the second snippet from your post. Another possible approach is to customize the template of RadButton.

    In case you choose to replace the Path with an image, you should have in mind that RadRibbonButton displays the image applied to the LargeImage property only when the button is in its Large state. In the other states (Small and Medium), the image set to the SmallImage property is shown. 

    If you decide to stick to the Path, keep in mind that you should handle the resizing of the image according to your preferences.

    Hope this is helpful.

    Regards,
    Tanya
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top