我希望能够在用户执行mousedown时触发事件 一个网格。 (就像用户点击网格而不是点击一样的视觉反馈!)
我有这个XAML代码:
// Save the stylesheet formats
stylesPart.Stylesheet.Save();
// Create custom widths for columns
Columns lstColumns = worksheetPart.Worksheet.GetFirstChild<Columns>();
Boolean needToInsertColumns = false;
if (lstColumns == null)
{
lstColumns = new Columns();
needToInsertColumns = true;
}
// Min = 1, Max = 1 ==> Apply this to column 1 (A)
// Min = 2, Max = 2 ==> Apply this to column 2 (B)
// Width = 25 ==> Set the width to 25
// CustomWidth = true ==> Tell Excel to use the custom width
lstColumns.Append(new Column() { Min = 1, Max = 1, Width = 25, CustomWidth = true });
lstColumns.Append(new Column() { Min = 2, Max = 2, Width = 9, CustomWidth = true });
lstColumns.Append(new Column() { Min = 3, Max = 3, Width = 9, CustomWidth = true });
lstColumns.Append(new Column() { Min = 4, Max = 4, Width = 9, CustomWidth = true });
lstColumns.Append(new Column() { Min = 5, Max = 5, Width = 13, CustomWidth = true });
lstColumns.Append(new Column() { Min = 6, Max = 6, Width = 17, CustomWidth = true });
lstColumns.Append(new Column() { Min = 7, Max = 7, Width = 12, CustomWidth = true });
// Only insert the columns if we had to create a new columns element
if (needToInsertColumns)
worksheetPart.Worksheet.InsertAt(lstColumns, 0);
// Get the sheetData cells
SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();
这是在c#类:
<Grid.Triggers>
<EventTrigger Event="MouseDown">
<local:MouseOver/>
</EventTrigger>
</Grid.Triggers>
即使课程正确实施,我仍然无法参加活动!我还尝试了 public class MouseOver : TriggerAction<Entry>
{
protected async override void Invoke(Entry entry)
{
//Some animation code here
}
}
和"IsMouseOver"
作为事件,但似乎没有任何效果。
我希望有人能帮助我......
谢谢你的帮助!
答案 0 :(得分:1)
EventTrigger
仅适用于Grid
类(或其中一个超类)上存在的事件。在XForms中,没有任何鼠标事件,因为它主要是为触摸界面设计的。
要向控件添加点按处理,我可以通过向控件上的TapGestureRecognizer
集合添加GestureRecognizers
来完成XForms。
// In C#
var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (s, e) => {
// handle the tap
};
image.GestureRecognizers.Add(tapGestureRecognizer);
// In XAML
<Grid Source="tapped.jpg">
<Grid.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
NumberOfTapsRequired="2" />
</Grid.GestureRecognizers>
</Grid>
您可以在XForms docs。
中阅读