Solved

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

Posted on 2010-11-24
8
991 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I want to trigger on only paragraphs that have a tag like 'para_with_formatting'
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 96

Accepted Solution

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

     needs to become

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

Author Comment

by:JElster
Comment Utility
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
Comment Utility
Did you figure out the conditions for the MultiTrigger?
0
 
LVL 1

Author Comment

by:JElster
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

12 Experts available now in Live!

Get 1:1 Help Now