Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello

I am working on desktop application in WPF. I have designed one glass button. with two ellipse in blender. One ellipse is base and another ellipse is glass effect one.

After applying it to resource dictionary I am not able to resize button in main window please help me to write resource dictionary .

code is

XML
<Grid Grid.Column="1" Margin="101,40,765,323" Grid.Row="2">
            <Ellipse Height="114"  Width="119" Margin="0,0,539,263">
                <Ellipse.Fill>
                    <RadialGradientBrush>
                        <GradientStop Color="#FF930F0F" Offset="1"/>
                        <GradientStop Color="#FFCB8181"/>
                    </RadialGradientBrush>
                </Ellipse.Fill>
            </Ellipse>

            <Ellipse  Margin="10,7,549,304">
                <Ellipse.Fill>
                    <LinearGradientBrush EndPoint="0.5,1" MappingMode="RelativeToBoundingBox" StartPoint="0.5,0">
                        <GradientStop Color="#00954141" Offset="1"/>
                        <GradientStop Color="#FFEAE8E8"/>
                    </LinearGradientBrush>
                </Ellipse.Fill>
            </Ellipse>

        </Grid>
Posted
Comments
Sergey Alexandrovich Kryukov 30-Nov-15 1:44am    
The ability to resize a custom control is not related to the dictionary itself.

You can achieve all the functionality by having styles with triggers and, most likely, ControlTemplates, and having some triggers' properties bound to the existing object properties, such as Width or Height. Even though the final result may look fairly simple, explanation of how to put it all together may need considerable time. I do have the application which does it all, but unfortunately 1) it's not so close to what you are doing, for example, I work not with size, and so on, 2) it won't be published sooner than next spring.

So, instead, I would recommend you to learn styling, triggers, ControlTemplates, and, importantly, WPF binding. With good effort, it could be done in 1-2 days to the degree covering your use cases. You can find good number of code samples...

—SA
johannesnestler 30-Nov-15 10:01am    
what is the code you Show here - is it the ControlTemplate for your CustomControl (not UserControl!) or what? -> then use template bindings to set the relevant size properties to the sizes of some inner elements - e.g your grid.... But as Sergey said - you will be lost if you don't know the basics about styling and ControlTemplates... sorry for that - but your use of the term ResourceDictionary is a hint you are a WPF beginner. In WPF "everything" can be a resource and many resources can be collected in a ResourceDictionary. Your prolbem is related to styling or a control template - I can't tell because you didn't show the relvant code - the drawing of ellipses itself isn't your problem...

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