【发布时间】:2013-11-01 04:51:14
【问题描述】:
我在我的 WP 应用程序中创建了一个自定义按钮。我想让它看起来像一个标准的 windows phone 8 按钮。 XAML 代码
<Grid Name="btnCancle" Height="76" Width="76" Margin="24" ManipulationStarted="btnCancle_ManipulationStarted" ManipulationCompleted="btnCancle_ManipulationCompleted" >
<Ellipse Name="ellipseCancle" Grid.Row="2" Stroke="{StaticResource PhoneForegroundBrush}" StrokeThickness="3" Height="76" Width="76" />
<Canvas x:Name="appbar_close" Width="76" Height="76" Clip="F1 M 0,0L 76,0L 76,76L 0,76L 0,0">
<Path Width="31.6666" Height="31.6667" Canvas.Left="22.1666" Canvas.Top="22.1667" Stretch="Fill" Fill="{StaticResource PhoneForegroundBrush}" Data="F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z "/>
</Canvas>
</Grid>
事件处理程序的代码
private void btnCancle_ManipulationStarted(object sender, System.Windows.Input.ManipulationStartedEventArgs e)
{
Brush br = (Brush)Application.Current.Resources["PhoneAccentBrush"];
ellipseCancle.Fill = br;
}
private void btnCancle_ManipulationCompleted(object sender, System.Windows.Input.ManipulationCompletedEventArgs e)
{
Brush br = (Brush)Application.Current.Resources["PhoneBackgroundBrush"];
ellipseCancle.Fill = br;
}
我的问题是,当我单击按钮时,在按钮充当正常按钮之前会有一点延迟。(背景更改为 PhoneAccentColor 并返回)。只要我触摸它,背景颜色就不会改变。但经过一两次尝试后,它表现正常。我正在编写代码以在 Tap 事件处理程序中执行该按钮的操作。但是一旦用户触摸它,我就需要让它像普通按钮一样工作。我做错了什么,我能做些什么来解决它?请帮忙..提前谢谢..
【问题讨论】:
标签: windows-phone-8 windows-phone