Solved

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

Posted on 2010-11-24
8
1,005 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

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…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

628 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