我的应用程序中有一些Listboxes绑定到ObservableCollections,我想动画一个项目,如果它被删除.
我已经发现了一个关于使用FrameworkElement.Loaded事件动画添加项目的问题,但当然这与Unloaded事件的工作方式不同.
有没有办法以可以在datatemplate中使用的方式执行此操作?
编辑:我已经连接到我的ItemsSource中的CollectionChanged事件,并尝试手动应用动画.目前它看起来像这样:
ListBoxItem item = stack.ItemContainerGenerator.ContainerFromIndex(0) as ListBoxItem;
item.LayoutTransform = new ScaleTransform(1, 1);
DoubleAnimation scaleAnimation = new DoubleAnimation();
scaleAnimation.From = 1;
scaleAnimation.To = 0;
scaleAnimation.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
ScaleTransform transform = (ScaleTransform)item.LayoutTransform;
transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
Run Code Online (Sandbox Code Playgroud)
问题是,它根本不起作用.该项目仍然只是弹出.当方法被调用时,该项目仍然存在,所以它不应该在它消失之前播放动画吗?或者我完全错了吗?
我在一个资源词典中有DataTemplate,在某些情况下,我需要按钮,我不知道如何使用代码来管理事件.
我试着在我的资源字典中放一个类:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SLProject.Templates"
x:Class="TVTemplate">
Run Code Online (Sandbox Code Playgroud)
我在cs文件中定义了这样的类:
namespace SLProject.Templates
{
partial class TVTemplate
{
}
}
Run Code Online (Sandbox Code Playgroud)
构建是正常的但是当应用程序启动时,我获得了以下XAML错误:
AG_E_PARSER_BAD_TYPE
我尝试了所有我知道的将类类更改为ClassModifier,使类成为继承的RessourceDictionnary类...没办法.
有人有想法......
谢谢.
我最近使用了 Expression Blend,我发现它有一个叫做 Visual State Manager 的东西,它和常规的事件驱动模型有什么区别,哪个更好?
我开始使用Blend for VS 2012RC,当我打开Blend然后转到时New Project,我看不到选择项目类型的选项.它完全是空的,如下所示.任何人都可以帮我解决这个问题.
我还尝试在VS2012RC中创建一个WPF项目并在Blend中打开它但我无法获得设计视图.

我听说过使用WPF(xaml设计师)和VS 2008-2010的投诉,但不是2012年的投诉.它仍然是使用Blend的标准还是VS 2012拥有我们需要的一切?我知道最近有一个版本"Blend for Visual Studio".这是神奇的整合吗?
这当然是假设我们没有设计师要求Blend.
在我看来,Trigger在Interactivity命名空间中找到的Blend-style 与在WPF中Trigger通过Styles,ControlTemplates等提供的经典s 之间存在重大差异(我认为这可能也适用于SilverLight).
在WPF中,当您Trigger使用Setter 设置a 时,您会得到两种行为:如果满足触发条件,则应用Setter.但是,一旦不再满足触发器,则恢复先前的值.这在编程UI时非常有用.
我尝试DataTrigger使用Blend方式编写类似的代码:我将ChangePropertyAction应用于我的控件,并DataTrigger使用绑定到我的ViewModel来触发Interactivity .
<Rectangle x:Name="SecondaryHighlightBackground" Fill="#FF505050">
<i:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding IsHighlighted}" Value="Value">
<ei:ChangePropertyAction PropertyName="Opacity" Value="0.5"/>
</ei:DataTrigger>
</i:Interaction.Triggers>
...
</Rectangle>
Run Code Online (Sandbox Code Playgroud)
所以这按预期工作......除了我惊讶地发现,当我将IsHighlighted值翻转为假时,原始不透明度0%未恢复(我将其设置为较低).为了仔细检查这个,我写了这个例子来验证:
<Window x:Class="TestWpfApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window"
Title="MainWindow"
Width="640"
Height="480">
<Grid x:Name="LayoutRoot">
<Button Name="button1"
Width="173"
Height="57"
Margin="10,10,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Button.Style>
<Style TargetType="Button">
<Setter Property="Content" Value="foo" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=button1}" Value="True">
<Setter Property="Content" Value="bar" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
预期的行为是,如果您将鼠标悬停在按钮上,则内容将更改为"bar".移动鼠标将内容恢复为'Foo',如Style所指定.样式设置内容以避免属性优先级问题.
我的问题是:Blend扩展中是否真的缺少双向触发,还是有办法以某种方式启用它? …
在Visual Studio和Blend 中打开相同的项目后,我使用前者编写代码,同时在后者中编辑 XAML。
当我将 UI 元素添加到 .xaml 文件并将其保存在 Blend 中时,如果我也在 Visual Studio 中打开了该文件,我会看到一些外部更改已完成的消息,并询问我是否希望它们在打开的文件*。我接受它,我可以看到更改在 Visual Studio 的 .xaml 文件中生效。
问题是,虽然新元素已添加到 .xaml 文件中,但我无法通过代码隐藏 .cs 文件中的 Intellisense 访问它们。
例如,如果我使用 Blend将以下元素添加到MainPage.xaml:
<Button x:Name="MyButton" Content="Button"/>
Run Code Online (Sandbox Code Playgroud)
我可以看到添加到Visual Studio中的页面,同一行,但使用的名字我不能访问它MyButton在MainPage.xaml.cs中的文件。智能感知不适用于它。如果我写,例如MyButton.Content = "Hello!";它是红色下划线,但是我可以构建和运行该项目。
重建项目并不能解决问题,并且在我“再次”在 Visual Studio 中保存文件之前,Intellisense 不起作用。
有时我觉得这种行为很烦人,我想知道这是正常行为,还是我的配置有问题。
*我通常不会在 Visual Studio 中打开它,只是为了避免在 Blend 中每次修改都显示该消息
我正在尝试调试在 Expression Blend 2013 中的 DesignTime 运行的某些代码的问题。
我有一个在 Blend 中加载的 Windows Store (8.1) 项目。我想调试 Blend 设计器中运行的一些 ViewModel 代码。
在之前的项目中,我在 Visual Studio 中打开了相同的项目,并对 Blend 执行了“调试 - 附加进程”。
我在当前的开发机器上看到的问题是所有断点都无效。他们显示警告
当前不会命中断点。该文档尚未加载任何符号
如果我只是在 Visual Studio 中调试 - 启动并部署到模拟器,这些断点就可以正常运行。为什么 Blend 不允许我附加和调试?
TIA
帕特·朗
mvvm expression-blend visual-studio-debugging visual-studio-2013
我对Silverlight和Expression Blend之间的区别感到有点困惑.根据我的理解,Silverlight用于创建更好的界面,Blend用于创建动画?这意味着你可以使用Silverlight而不必使用Expression Blend(对Silverlight开发人员有很多需求,但据我所知,Silverlight很容易掌握).您可以在不使用Blend的情况下使用Silverlight,但不能在不使用Silverlight的情况下使用Blend.这是对的吗?
如何在尚未拥有的控件上创建BehaviorCollection?
expression-blend ×10
wpf ×5
xaml ×4
.net ×3
c# ×3
silverlight ×2
blend ×1
blend-2012 ×1
datatrigger ×1
event-driven ×1
intellisense ×1
mvvm ×1
vsm ×1