none
:: MenuCustomizado MultiTrigger Erro RRS feed

  • Pergunta

  • Olá pessoal,

     

    Eu estou tentando criar um usercontrol com um menu customizado, mas estou tendo um problema com o MultiTrigger, segue o codigo abaixo:

     

    Code Snippet

    <UserControl x:Class="MeusControles.ucMenu"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <UserControl.Resources>

    <Style TargetType="{x:Type MenuItem}">

    <Setter Property="Template">

    <Setter.Value>

    <ControlTemplate TargetType="{x:Type MenuItem}">

    <Border x:Name="Borda"

    Background="{TemplateBinding Background}"

    Opacity="0.6"

    BorderThickness="1"

    Margin="2"

    Padding="3">

    <Grid>

    <Grid.ColumnDefinitions>

    <ColumnDefinition Width="Auto" />

    <ColumnDefinition Width="20" />

    </Grid.ColumnDefinitions>

    <ContentPresenter x:Name="HeaderItem"

    ContentSource="Header"

    Margin="{TemplateBinding Padding}" />

    <Grid Grid.Column="1" Visibility="Hidden" Margin="4,0,6,0" x:Name="arrowPanel" VerticalAlignment="Center">

    <Path x:Name="arrowPanelPath" VerticalAlignment="Center" Fill="Black" Data="M 0,0 L 8,0 L 4,4 Z" />

    </Grid>

    </Grid>

    </Border>

    <ControlTemplate.Triggers>

    <MultiDataTrigger>

    <MultiTrigger.Conditions>

    <Condition Property="Role" Value="TopLevelHeader" />

    <Condition Property="IsMouseOver" Value="True" />

    </MultiTrigger.Conditions>

    <Setter Property="Visibility" Value="Visible" TargetName="arrowPanel" />

    <Setter Property="Opacity" Value="1" TargetName="Borda" />

    <Setter Property="Background" TargetName="Borda">

    <Setter.Value>

    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">

    <GradientStop Color="sc#1, 0.813324332, 0.9436713, 1" Offset="0.032051282051282048"/>

    <GradientStop Color="sc#1, 0.7551608, 0.8902375, 0.999111533" Offset="1"/>

    </LinearGradientBrush>

    </Setter.Value>

    </Setter>

    <Setter Property="BorderBrush" Value="Gray" TargetName="Borda" />

    </MultiDataTrigger>

    </ControlTemplate.Triggers>

    </ControlTemplate>

    </Setter.Value>

    </Setter>

    </Style>

    </UserControl.Resources>

    <Menu Background="{x:Null}"

    Margin="5"

    FontFamily="Verdana"

    FontSize="11"

    FontWeight="Bold">

    <MenuItem Header="Item 1">

    <MenuItem Header="SubItem 1"></MenuItem>

    <MenuItem Header="SubItem 2"></MenuItem>

    </MenuItem>

    <MenuItem Header="Item 2">

    <MenuItem Header="SubItem 1"></MenuItem>

    <MenuItem Header="SubItem 2"></MenuItem>

    </MenuItem>

    </Menu>

    </UserControl>

     

     

     

    O erro que esta dando é o seguinte:

    • The attached property 'MultiTrigger.Conditions' is not defined on 'MultiDataTrigger' or one of its base
    • The attachable property 'Conditions' was not found in type 'MultiTrigger'.

    Alguem sabe me dizer o pq disso?

    quinta-feira, 23 de outubro de 2008 02:52

Respostas

  • Tente modificar o código desta forma:

     

    Code Snippet

    <UserControl x:Class="MeusControles.ucMenu"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">


        <UserControl.Resources>

            <Style TargetType="{x:Type MenuItem}">

                <Setter Property="Template">

                    <Setter.Value>

                        <ControlTemplate TargetType="{x:Type MenuItem}">

                            <Border x:Name="Borda"

    Background="{TemplateBinding Background}"

    Opacity="0.6"

    BorderThickness="1"

    Margin="2"

    Padding="3">

                                <Grid>

                                    <Grid.ColumnDefinitions>

                                        <ColumnDefinition Width="Auto" />

                                        <ColumnDefinition Width="20" />

                                    </Grid.ColumnDefinitions>


                                    <ContentPresenter x:Name="HeaderItem"

    ContentSource="Header"

    Margin="{TemplateBinding Padding}" />

                                    <Grid Grid.Column="1" Visibility="Hidden" Margin="4,0,6,0" x:Name="arrowPanel" VerticalAlignment="Center">

                                        <Path x:Name="arrowPanelPath" VerticalAlignment="Center" Fill="Black" Data="M 0,0 L 8,0 L 4,4 Z" />

                                    </Grid>

                                </Grid>

                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>


                <Style.Triggers>

                    <MultiTrigger>

                        <MultiTrigger.Conditions>

                            <Condition Property="Role" Value="TopLevelHeader" />

                            <Condition Property="IsMouseOver" Value="True" />

                        </MultiTrigger.Conditions>

                        <Setter Property="Visibility" Value="Visible" TargetName="arrowPanel" />

                        <Setter Property="Opacity" Value="1" TargetName="Borda" />

                        <Setter Property="Background" TargetName="Borda">

                            <Setter.Value>

                                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">

                                    <GradientStop Color="sc#1, 0.813324332, 0.9436713, 1" Offset="0.032051282051282048"/>

                                    <GradientStop Color="sc#1, 0.7551608, 0.8902375, 0.999111533" Offset="1"/>

                                </LinearGradientBrush>

                            </Setter.Value>

                        </Setter>

                        <Setter Property="BorderBrush" Value="Gray" TargetName="Borda" />

                    </MultiTrigger>

                    </Style.Triggers>

            </Style>

        </UserControl.Resources>

     

     

     

    Abraços.
    quinta-feira, 23 de outubro de 2008 09:28