Solved

Help with TargetType  - How do I selectivity set the targer to some and not others?

Posted on 2010-11-24
8
994 Views
Last Modified: 2013-11-12
Hi..
I have the following XAML... But I want to apply it some Paragraphs and not others how can I do that?
thanks

   
           
            <Style TargetType="Paragraph">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="TextDecorations" Value="Underline" />
                    </Trigger>
                </Style.Triggers>
            </Style>


0
Comment
Question by:JElster
  • 4
  • 4
8 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34209694
When you need to customize behavior for certain paragraphs, then you need to know how to differentiate each Paragraph object.  One possible solution might be to store something in the Tag property that will let you identify the paragraph.
0
 
LVL 1

Author Comment

by:JElster
ID: 34209812
Ok.. I can add a TAG to the paragraphs... I'm creating the paragraphs in code.
How do I apply the above style to only those paragraphs  e.g  Tag like 'para_With_Formatting'?
thx
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34210532
The Trigger behavior is dependent on the Paragraph.IsMouseOver property.  Are you asking for a combination trigger with Paragraph.Tag?

For multiple conditions, you would need a MultiTrigger:

<MultiTrigger>
      <MultiTrigger.Conditions>
        <Condition Property="Content" Value="a" />
        <Condition Property="IsMouseOver" Value="True" />
      </MultiTrigger.Conditions>
      <Setter Property="Visibility" Value="Collapsed" />
</MultiTrigger>

Open in new window

0
 
LVL 1

Author Comment

by:JElster
ID: 34212122
I want to trigger on only paragraphs that have a tag like 'para_with_formatting'
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 96

Accepted Solution

by:
Bob Learned earned 350 total points
ID: 34217704
<Trigger Property="IsMouseOver" Value="True">

     needs to become

<Trigger Property="Tag" Value="para_with_formatting">
0
 
LVL 1

Author Comment

by:JElster
ID: 34225240
I get the following message...

Error      5      'Tag' member is not valid because it does not have a qualifying type name.

  <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="Tag" Value="paragraph_with_hyperlink" />
                    <Condition Property="IsMouseOver" Value="True" />
                </MultiTrigger.Conditions>
               <Setter Property="TextDecorations" Value="Underline" />
            </MultiTrigger>
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34227186
Did you figure out the conditions for the MultiTrigger?
0
 
LVL 1

Author Comment

by:JElster
ID: 34227210
Yes...
 <Style TargetType="{x:Type Paragraph}">
                 <Style.Triggers>
                    <MultiTrigger>
                        <MultiTrigger.Conditions>
                            <Condition Property="IsMouseOver" Value="True" />
                            <Condition Property="Tag" Value="paragraph_with_hyperlink" />
                        </MultiTrigger.Conditions>
                        <Setter Property="TextDecorations" Value="Underline" />
                        <Setter Property="Foreground" Value="Blue"/>
                    </MultiTrigger>
                </Style.Triggers>
            </Style>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now