繁体   English   中英

在Silverlight上为Windows Phone C#创建自定义按钮

[英]Creating Customised button on silverlight for windows phone c#

大家好,我想创建一个自定义按钮,该按钮看起来像聊天对话框的形状,而不是普通的矩形。 我可以知道怎么做吗?

我尝试了expression blend,但是效果不佳,阅读了一下,发现它更像是为它创建一个库,这样我就可以导入工作了。

如果有人可以向我展示一些有关如何使用当前VS或表达式混合(最可能是这种情况)来完成此操作的教程,那将是很好的选择,

提前致谢!

问候,TransformBinary大家好,对不起,我错过了这一点,它是一个代码生成的按钮

意思是我想
MyButton btn = new MyButton();
代替
Button btn = new Button();

看看这个例子还是这一个 它与WPF有关,但是在Silverlight中,情况将完全相同。 Google可能会提供大量此类教程,例如通过“按钮模板混合wpf”进行搜索。

我从Visual Studio创建了一个用户控件,然后单击鼠标右键,然后将其移到Expression Blend中,我设法创建了自定义按钮,但是我向其中添加了一个事件处理程序,我无法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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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