【发布时间】:2018-04-30 22:14:38
【问题描述】:
这是我的 C# 和 XAML 示例 UWP 代码 我在 MainPage 方法中创建了一个超链接按钮,并设置了前景和背景等样式属性。
现在我想在像鼠标悬停一样触发 PointerEntered 事件时更改背景和前景色,在这种情况下,只有字体大小会改变,颜色不会改变
public MainPage(){
this.InitializeComponent();
var hLinkButton = new HyperlinkButton();
hLinkButton.Name = "LearnMoreHyperLink";
hLinkButton.Content = "Learn More...";
hLinkButton.Background = new SolidColorBrush(Colors.Red);
hLinkButton.Foreground = new SolidColorBrush(Colors.White);
hLinkButton.FontWeight = FontWeights.SemiBold;
hLinkButton.FontSize = 18.0;
hLinkButton.PointerEntered += OnPointerEntered;
LayoutGrid.Children.Add(hLinkButton);
}
private void OnPointerEntered(object sender, PointerRoutedEventArgs e){
var hLButton = sender as HyperlinkButton;
hLButton.Background = new SolidColorBrush(Colors.White);
hLButton.Foreground = new SolidColorBrush(Colors.Red);
hLButton.FontSize = 30.0;
}
// Only fontsize effecting on mouseover, background and foreground is not working
【问题讨论】:
标签: c# uwp windows-10-universal uwp-xaml