我们有一个简单的动画,在检查和取消选中ToggleButton时运行(展开ListView的高度,然后折叠ListView的高度).如何在以下XAML中<Storyboard x:Key="CommentsCollapse">的GridConnge绑定更改时触发EventTrigger(或Animation)x:Name="DetailsGrid"?
换句话说,每当"DetailsGrid"的Binding更改时,我们都希望触发"CommentsCollapse"StoryBoard以确保ListView返回到其折叠状态.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="800"
Height="400">
<Page.Resources>
<Storyboard x:Key="CommentsExpand">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="CommentsListView"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200" Value="300"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="CommentsCollapse">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="CommentsListView"
Storyboard.TargetProperty="(FrameworkElement.Height)">
<SplineDoubleKeyFrame KeyTime="00:00:00.200" Value="75"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<Page.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked" SourceName="CommentsToggleButton">
<BeginStoryboard Storyboard="{StaticResource CommentsExpand}"/>
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked" SourceName="CommentsToggleButton">
<BeginStoryboard Storyboard="{StaticResource CommentsCollapse}"/>
</EventTrigger>
</Page.Triggers>
<Grid DataContext="{Binding Path=CurrentTask.Workflow.Invoice}" x:Name="DetailsGrid">
<StackPanel Orientation="Horizontal">
<Canvas Width="428">
<GroupBox Width="422" Margin="5,0,0,0">
<GroupBox.Header>
<StackPanel Orientation="Horizontal">
<ToggleButton
x:Name="CommentsToggleButton"
Width="20"
Height="10"
Margin="5,0,0,0">
<ToggleButton.Content>
<Rectangle
Width="5"
Height="5"
Fill="Red"/>
</ToggleButton.Content>
</ToggleButton>
<TextBlock Foreground="Blue" …Run Code Online (Sandbox Code Playgroud) 这可能非常简单 - 但我很难发现正在发生的事情.
关于JS小提琴:http: //jsfiddle.net/3hHAX/
有两个链接输出到'打开视频模态'.
由于链接文本表明这两个链接应打开包含youtube视频的模型弹出窗口.
这是使用来自以下网站的prettyphoto库:http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/
由于某种原因,单击事件不会在第一次单击时触发.但是第二个工作.
(没有包含CSS所以看起来不是很模态,但你会看到下面的内容加载至少为了演示的目的).
任何人都可以建议出错的地方?
谢谢,
史蒂夫
我正在使用MvmmCross v3框架和Windows.UI.Interactivity开发 WinRT .
我想在TextChanged事件上使用带有EventTrigger的TextBox来启动Command.而且,我想在CommandParameter中使用textBox的文本.
所以我有这个代码
<i:EventTrigger EventName="TextChanged">
<i:InvokeCommandAction Command="{Binding UpdateText}" CommandParameter="{Binding Text}"/>
</i:EventTrigger>
public ICommand UpdateText
{
get
{
return new MvxCommand<object>((textSearch) =>
{
// code...
});
}
}
Run Code Online (Sandbox Code Playgroud)
但我的textSearch参数等于"{Windows.UI.Xaml.Controls.TextChangedEventArgs}",所有这些属性都为NULL.
我试图在绑定中明确声明我的ElementName
CommandParameter="{Binding Path=Text, ElementName=tes}
Run Code Online (Sandbox Code Playgroud)
但它也失败了.
谢谢
xaml eventtrigger commandparameter windows-runtime mvvmcross
我有一个UITextField,我需要以编程方式选择,所以当用户点击UIDatePicker中的日期时,它将被发送到该UITextField.
这是我的代码,它没有选择UITextField; 我已经尝试了UIControlEvent的所有可能组合,但它们都不起作用.还有其他想法吗?
// set textField parameters
if([whichTextField isEqualToString:@"oStartTime"]) {
oStartTime.backgroundColor = [UIColor colorWithRed:252.0/255.0 green:255.0/255.0 blue:197.0/255.0 alpha:1.0];
[oStartTime sendActionsForControlEvents: UIControlEventTouchUpInside];
}
else if([whichTextField isEqualToString:@"oFinishTime"]) {
oFinishTime.backgroundColor = [UIColor colorWithRed:252.0/255.0 green:255.0/255.0 blue:197.0/255.0 alpha:1.0];
[oFinishTime sendActionsForControlEvents: UIControlEventTouchUpInside];
}
Run Code Online (Sandbox Code Playgroud) 我在带有caliburn的Windows Phone 8上开发了应用程序.在我的一个页面上,我在datatemplate中有一个按钮,我在鼠标点击时设置了触发器:
<DataTemplate>
<Button>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro1:ActionMessage MethodName="GoToPage">
<micro1:Parameter Value="{Binding Path=PageId}" />
</micro1:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
<TextBlock Text="{Binding Path=PageDescription}" TextWrapping="Wrap"
HorizontalAlignment="Center" VerticalAlignment="Center" />
</Button>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
它工作正常.现在我已经在Windows Phone 8.1(winrt)上创建了新的应用程序,但是使用相同的代码我在触发器上出错了.我怎么能在wp 8.1上做到这一点?我找到了winrttriggers.codeplex.com,但它与wp 8.1平台不兼容.
非常感谢!
编辑1:
使用您的代码,我的视图不会触发命令.我现在有:
<i:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="Click">
<core:InvokeCommandAction Command="{Binding OpenPageCommand}" CommandParameter="{Binding Path=PageId}" />
</core:EventTriggerBehavior>
</i:Interaction.Behaviors>
Run Code Online (Sandbox Code Playgroud)
我的命令是委托命令:
public class DelegateCommand<T> : ICommand
{
private readonly Func<T, bool> _canExecuteMethod;
private readonly Action<T> _executeMethod;
#region Constructors
public DelegateCommand(Action<T> executeMethod)
: this(executeMethod, null)
{
}
public DelegateCommand(Action<T> executeMethod, Func<T, bool> canExecuteMethod)
{
_executeMethod = …Run Code Online (Sandbox Code Playgroud) 我正在使用jquery.tagsinput,并希望能够粘贴以逗号或空格分隔的电子邮件地址列表.使用类似这样的东西https://github.com/xoxco/jQuery-Tags-Input/issues/22但它不会添加它们直到我按Enter键 - 尝试触发按键输入事件但它不起作用.模糊事件也没有运气(如下所示).有任何想法吗?
Flat-UI标签基于这个库,我试图实现一个非常相似的行为.
var tidyTags = function(e) {
var tags = (e.tags).split(/[ ,]+/);
var target = $(e.target);
for (var i = 0, z = tags.length; i<z; i++) {
var tag = $.trim(tags[i]);
if (!target.tagExist(tag)) {
target.addTag(tag);
}
}
$('#' + target[0].id + '_tag').trigger('focus');
//This doesn't work.
target.blur();
};
$("#tagsinput").tagsInput({
onAddTag : function(tag){
if(tag.indexOf(',') > 0) {
tidyTags({target: '#tagsinput', tags : tag});
}
},
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个MVVM WPF应用程序,该应用程序允许我在窗口中绘制一个矩形。现在,我已经创建了一个画布元素来覆盖整个屏幕。继等问题,并指导,它看起来像使用鼠标事件命令绑定(如只有这样MouseDown,MouseUp等)是组装使用System.Windows.Interactivity并添加EventTriggers的鼠标事件。但是,这似乎不适用于canvas元素。单击,单击/按住,单击/拖动,右键单击,它们都不会触发我的命令的Execute方法。
canvas元素支持哪些事件?为什么会MouseDown或PreviewMouseDown无法正常工作?
窗口的XAML:
<Window x:Class="RutheniumReader.SnippingWindow.SnippingShade"
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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:snippingWindow="clr-namespace:MyApp.SnippingWindow"
mc:Ignorable="d"
Title="Snipping Window"
WindowState="Maximized"
Background="Black"
>
<Window.DataContext>
<snippingWindow:SnippingWindowViewModel />
</Window.DataContext>
<Canvas x:Name="Canvas">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<i:InvokeCommandAction Command="{Binding Path=MouseDownCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Canvas>
</Window>
Run Code Online (Sandbox Code Playgroud)
出于测试目的,我尝试了以下运气不佳的事件:
Button画布内的元素,则可以使用Button元素一起使用<font>如果它们的父元素具有 .menuItem 类名,我试图捕获所有标签的点击事件。
我制作的触发器看起来像:
Click Classes matches CSS selector .menuItem > font
Run Code Online (Sandbox Code Playgroud)
但它不会触发。这里缺少什么?
我有两个脚本。
第一个脚本包含游戏的原型类。这个类使用严格,并且没有准备好文档。触发:
$("#trigger").trigger("noPossibilities");
Run Code Online (Sandbox Code Playgroud)
在同样使用严格的第二个脚本中,我尝试捕获触发器:
$(document).ready(function() {
$("#trigger").on("noPossibilities", function() {
console.log("noPossibilities trigger");
});
});
Run Code Online (Sandbox Code Playgroud)
问题是我无法抓住扳机。这可能与使用严格/范围有关,但我似乎无法找到解决方法。
真的希望有人能帮助我
更新 第一个脚本有一个原型类。
这个类在第二个脚本中被实例化。在处理程序之后。然后它仍然不起作用,因为第一个脚本在第二个脚本之前加载?
同样,当我从控制台执行这一行时:
$("#trigger").trigger("noPossibilities");
Run Code Online (Sandbox Code Playgroud)
它不会被触发。不应该这样工作吗?
更新 2
我发现了问题。第一个脚本在实例化时将带有 id 触发器的元素添加到文档中。我在游戏开始时有一个弹出窗口。现在,单击该按钮即可附加处理程序。
该文档可能没有处理程序应该附加到的元素。现在它稍后被附加,现在它正在工作。
我想在滚动视图的内容上实现拖放。
问题是,当您尝试在滚动视图中拖动项目时,无法滚动视图。
首先,我尝试通过IDragHandler,IBeginDragHandler,IEndDragHandle和IDropHandler接口实现拖放。乍一看,它工作得很好,但问题是您无法滚动ScrollRect。
我认为问题是由于重载造成的,当我使用事件触发器与拖动一样像rect rect时,父触发器无法正常工作。
因此,在那之后,我自己思考了一下,并通过IPointerDown,IPointerUp接口和在ScrollRect中保留可拖动UI的特定时间来实现它,如果您没有在特定时间保持它,则滚动工作会很好。
但是问题是通过启用在保持时间结束时在OnDrag,OnBeginDrag和OnEndDrag函数之前编写的DragHandler脚本不起作用。
首先我想知道有什么方法可以调用这些函数吗?
其次,有什么方法可以在不使用拖动界面的情况下实现拖放UI?
DragHandler:
using System;
using UnityEngine;
using UnityEngine.EventSystems;
public class DragHandler : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDragHandler
{
public static GameObject itemBeingDragged;
private Vector3 startPos;
private Transform startParent;
DragHandler dragHandler;
public void Awake()
{
dragHandler = GetComponent<DragHandler>();
}
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("Begin");
itemBeingDragged = gameObject;
startPos = transform.position;
startParent = transform.parent;
}
public void OnDrag(PointerEventData eventData)
{
Debug.Log("Drag");
transform.position = Input.mousePosition;
}
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("End");
itemBeingDragged = null; …Run Code Online (Sandbox Code Playgroud) drag-and-drop eventtrigger scrollrect scrollview unity-game-engine
eventtrigger ×10
jquery ×3
wpf ×2
xaml ×2
c# ×1
data-binding ×1
ios6 ×1
javascript ×1
mvvm ×1
mvvmcross ×1
onclick ×1
paste ×1
scope ×1
scrollrect ×1
scrollview ×1
storyboard ×1
strict ×1
tags ×1
uitextfield ×1
xcode4.6 ×1