我收到了一个非常烦人的错误
错误175 XML名称空间“http://schemas.microsoft.com/winfx/2006/xaml/presentation”中不存在标记“DataTrigger”。
我正在使用带有Silverlight 5的Visual Studio 2010.据我所知,引用是好的,但显然不是,有人可以告诉我是什么原因造成的吗
我相信这可能会解决我之前提出的其他问题,但由于此错误无法对其进行测试
Change DataTemplate to use depending on condition
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
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:iv="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
mc:Ignorable="d"
>
<UserControl.Resources>
<DataTemplate x:Key="SelectControl">
<ContentControl Content="{Binding}">
<ContentControl.Style>
<Style TargetType="ContentControl">
<Style.Triggers>
<DataTrigger Binding="{Binding BlockType}" Value="Locked">
<Setter Property="DataTemplate"
Value="{StaticResource LockedClip}" />
</DataTrigger>
<DataTrigger Binding="{Binding BlockType}" Value="Unlocked">
<Setter Property="DataTemplate"
Value="{StaticResource UnlockedClip}" />
</DataTrigger>
<DataTrigger Binding="{Binding BlockType}" Value="Unlock">
<Setter Property="DataTemplate"
Value="{StaticResource UnlockClip}" />
</DataTrigger>
</Style.Triggers>
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
<DataTemplate x:Key="LockedClip">
<my:SingleLockedFlexBlock Height="117"/>
</DataTemplate>
<DataTemplate x:Key="UnlockedClip">
<my:SingleLockedFlexBlock Height="50"/>
</DataTemplate>
<DataTemplate x:Key="UnlockClip">
<my:SingleLockedFlexBlock Height="200"/>
</DataTemplate>
希望有人能说清楚这一点吗?
保
答案 0 :(得分:2)
DataTrigger
,但您可以使用Blend Preview for SL5中的SDK来获取相应的行为。
您可能需要查看:
XAML代码明智,我相信您需要更改以下内容:
<Style.Triggers>
<DataTrigger Binding="{Binding BlockType}" Value="Locked">
<Setter Property="DataTemplate"
Value="{StaticResource LockedClip}" />
</DataTrigger>
...
进入以下内容:
<iv:Interaction.Triggers>
<ei:DataTrigger Binding="{Binding BlockType}" Value="Locked">
<ei:ChangePropertyAction PropertyName="DataTemplate"
Value="{StaticResource LockedClip}" />
</ei:DataTrigger>
...