Divelements Community
Customer discussion of all Divelements products

How to make a sandribbonbutton from XAML vector description?

Latest post 09-15-2008 9:06 by Tim Dawson. 1 replies.
  • 09-08-2008 11:54

    • xiasma
    • Not Ranked
    • Joined on 09-08-2008
    • Posts 1

    How to make a sandribbonbutton from XAML vector description?

    I've got a class described in XAML as xiasma.icons.myusercontrol which looks a little like this:

    <UserControl
    	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/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    	x:Class=" xiasma.icons"
    	x:Name="myusercontrol"
    	Width="48" Height="48">
    
        <Grid x:Name="LayoutRoot">
            <Ellipse Margin="12,12,12,12" Stroke="#000000" StrokeThickness="2" x:Name="Circle">
                <Ellipse.Fill>
                    <LinearGradientBrush StartPoint="1,0.8" EndPoint="0,0.5" SpreadMethod="Pad">
                        <GradientStop Color="#FF7C3D4C" Offset="0"/>
                        <GradientStop Color="#FFFD93AD" Offset="1"/>
                    </LinearGradientBrush>
                </Ellipse.Fill>
            </Ellipse>
            <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" StrokeThickness="7" Margin="18.5,12.5,18.5,12.5" Data="M0,8 L0,16" />
            <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="#FF000000" StrokeThickness="7" Margin="12.5,18.5,12.5,18.5" Data="M8,8 L16,8" />
        </Grid>
    </UserControl>
    
    
    
    I want to populate a sandribbon group dynamically at runtime with each instance of the button being a different colour 
    eg the "Circle" brush would be programmatically altered.
    
    
    Now, I don't care what type xiasma.icons.myusercontrol is - it's a usercontrol so I could use the editor. But because the brush isn't known until runtime, I can't pre-render a bitmap to assign to the sandribbon.button.image property.
    At the moment, I just add the usercontrols to the ribbongroup, but this isn't very good as the mouseover effects don't match those of "real" sandribbon buttons.
    
    
    Am I doing something fundamentally wrong? 
    
    
    Thanks in advance,
    
    
    Adrian
  • 09-15-2008 9:06 In reply to

    Re: How to make a sandribbonbutton from XAML vector description?

    An ellipse or a usercontrol is not reusable as an image. You should instead use a DrawingImage, setting its Drawing property to a DrawingGroup containing an ellipse primitive with the dynamic brush you spoke of. This can then be directly assigned to the Image property of one or more buttons.

Page 1 of 1 (2 items) | RSS
Copyright © 2008 Divelements Limited
Powered by Community Server (Commercial Edition), by Telligent Systems