Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CSS
Hi, good day to all.


I already have the desired function working, what I want is to be able to change the color of the image that is generated by a resource that serves me for all the buttons.


I already have the resource as well:


XML
<DrawingImage x:Key="Atras">
    <DrawingImage.Drawing>
        <DrawingGroup>
            <GeometryDrawing Brush="{StaticResource scbSecundario}" Geometry="M18.701601,11.259598 L24.610021,11.259598 13.995821,21.873798 42,21.873798 42,26.047437 13.995821,26.047437 24.610021,36.661637 24.53408,36.740394 18.779225,36.740394 8.9530749,26.913694 5.9999977,23.960617 z M24,2.2574263 C11.991908,2.2574263 2.2574253,11.991908 2.2574255,24 2.2574253,36.008094 11.991908,45.742574 24,45.742574 36.008092,45.742574 45.742572,36.008094 45.742572,24 45.742572,11.991908 36.008092,2.2574263 24,2.2574263 z M24,0 C37.254835,0 48,10.745167 48,24 48,37.254834 37.254835,48.000001 24,48.000001 10.745166,48.000001 -4.7683714E-07,37.254834 1.5870416E-14,24 -4.7683714E-07,10.745167 10.745166,0 24,0 z"/>
            <!--<GeometryDrawing Brush="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type u:BotonConImagen}, Path=ColorImagen}" Geometry="M18.701601,11.259598 L24.610021,11.259598 13.995821,21.873798 42,21.873798 42,26.047437 13.995821,26.047437 24.610021,36.661637 24.53408,36.740394 18.779225,36.740394 8.9530749,26.913694 5.9999977,23.960617 z M24,2.2574263 C11.991908,2.2574263 2.2574253,11.991908 2.2574255,24 2.2574253,36.008094 11.991908,45.742574 24,45.742574 36.008092,45.742574 45.742572,36.008094 45.742572,24 45.742572,11.991908 36.008092,2.2574263 24,2.2574263 z M24,0 C37.254835,0 48,10.745167 48,24 48,37.254834 37.254835,48.000001 24,48.000001 10.745166,48.000001 -4.7683714E-07,37.254834 1.5870416E-14,24 -4.7683714E-07,10.745167 10.745166,0 24,0 z"/>-->
        </DrawingGroup>
    </DrawingImage.Drawing>
</DrawingImage>


Then I apply a style to the user control:

XML
<Style x:Key="BotonVacio" TargetType="{x:Type u:BotonConImagen}">
    <Setter Property="Focusable" Value="False" />
    <Setter Property="IsTabStop" Value="False" />
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type u:BotonConImagen}">
                <Grid Cursor="Hand">
                    <Image
                        Stretch="Fill"
                        Source="{TemplateBinding Imagen}"
                        Margin="5" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>


And this is the control already in the user interface:

XML
<u:BotonConImagen ColorImagen="Red" Style="{StaticResource BotonVacio}" Imagen="{StaticResource Atras}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="50" Height="50" Margin="10,16,0,0" Command="{Binding Padre.Padre.ComandoMostrarPrincipal}">
</u:BotonConImagen>


Which works great, the problem is that I need to take the color that I set up in the control using the ColorImagen property, I hope is clear question, and someone can work together with a solution or suggestion to try to achieve the desired objective.

In advance thousand thanks to all.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900