0

I am getting a really annoying error

Error 175 The tag 'DataTrigger' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'.

I am using Visual Studio 2010 with Silverlight 5. As far as I can tell the references are ok but obviously not, can someone tell me what is causing this please

I believe this may resolve the other question I raised earlier but cant test it because of this error

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>    

Hope someone can shed light on this?

Paul

1 Answer 1

2

DataTrigger is not supported by default in Silverlight, but you could use the SDK from the Blend Preview for SL5 to obtain corresponding behavior.

You might want to take a look at:

XAML code wise, I believe you need to change the following:

<Style.Triggers>
    <DataTrigger Binding="{Binding BlockType}" Value="Locked">
        <Setter Property="DataTemplate"
            Value="{StaticResource LockedClip}" />
    </DataTrigger>
    ...

into the following:

<iv:Interaction.Triggers>
    <ei:DataTrigger Binding="{Binding BlockType}" Value="Locked">
        <ei:ChangePropertyAction PropertyName="DataTemplate"
            Value="{StaticResource LockedClip}" />
    </ei:DataTrigger>
    ...
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks I got passed the compile errors but still cant get this to work. There is a comment saying add at the same level as Visual State for the control but I have no idea what level that is?
@Paul I have had some problems getting the trigger to activate myself, but I have at least updated my answer with some code that should hopefully be of help.
Thanks Anders I will try this when I get back to the office :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.