简体   繁体   中英

Creating Customised button on silverlight for windows phone c#

Hello everyone i would like to create a customised button which looks like a chat dialog shape instead of the normal rectangle . May i know how would i be able to do so?

I tried expression blend but it didnt work out well, read about it and found out that its more like creating a library for it so i can import the work.

Would be nice if someone could show me some tutorials on how it can be done using either the current VS or expression blend which most likey is the case,

THanks in advance!

Regards, TransformBinary Hi guys, sry that i missed this point out, its a code generated button

Meaning i'm trying to
MyButton btn = new MyButton();
instead of
Button btn = new Button();

Take a look at this example or this one . It's about WPF but in Silverlight things will be absolutely the same. Google may give tons of such tutorials, eg search by "button template blend wpf".

I created a user control from visual studio and right click then brought it over to Expression blend I manage to create the customized button but i add a event handler to it, i cant Btn.Click :\\

  <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/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:edc="clr-namespace:Microsoft.Expression.Controls;assembly=Microsoft.Expression.Drawing"
    mc:Ignorable="d"
    x:Class="Volunteer.LayoutRootControl" Height="127" Width="200">
    <UserControl.Resources>
        <Style x:Key="ButtonStyle8" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <edc:Callout AnchorPoint="0.85,1.19" CalloutStyle="Rectangle" Fill="#FFE054EF" FontSize="14.666999816894531" Stroke="Black"/>
                            <ContentPresenter Height="96" Width="196"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Button Style="{StaticResource ButtonStyle8}" HorizontalAlignment="Left" Height="102" VerticalAlignment="Top" Width="200">
        <Button.Content>
            <StackPanel Orientation="Horizontal" Width="197" Margin="-40,-34,-41,-32">
                <TextBlock Width="196" x:Name="BtnIN3" Text="" FontSize="22" TextWrapping="Wrap" Margin="0,0,0,-12" Height="95" />
            </StackPanel>
        </Button.Content>
    </Button>
</UserControl>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM