Solved

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

Posted on 2010-11-24
8
1,003 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 1

Author Comment

by:JElster
ID: 34212122
I want to trigger on only paragraphs that have a tag like 'para_with_formatting'
0
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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