Create resource for an image + tooltip that you will use many times in the graphical environment

0

I have the following code;

           <Image Source="C:\Users\Casa PC\Documents\Visual Studio 2017\Projects\PcS7\PcS7\Icons\info.png" Height="22" Margin="0,0,0,2">
                         <Image.ToolTip>
                             <StackPanel>
                                 <TextBlock FontWeight="Bold" FontSize="14" Margin="0,0,0,5">Ruta de archivo...</TextBlock>
                                 <TextBlock Text="El archivo se guardará en el siguiente directorio;"/>
                                 <TextBlock></TextBlock>
                                 <TextBlock Text="{Binding ruta, Mode=TwoWay}"/>
                                 <Border BorderBrush="Silver" BorderThickness="0,1,0,0" Margin="0,8" />
                                 <StackPanel Orientation="Horizontal">
                                     <Image Source="C:\Users\Casa PC\Documents\Visual Studio 2017\Projects\PcS7\PcS7\Icons\info.png" Margin="0,0,5,0" />
                                     <TextBlock VerticalAlignment="Center" FontStyle="Italic">Presione F1 para mas información</TextBlock>
                                 </StackPanel>
                             </StackPanel>
                         </Image.ToolTip>
           </Image>

This is an image that raises a tootltip when you pass the mouse over and that tells you the status of certain parts of the program, the idea is to have a template of that code and be able to use it in many parts of this without having to continuously repeat all the code again and again. I understand that there is the possibility of using resources that do what I'm looking for, but I can not fully understand them and I have preferred to ask them in the forum and be someone with more experience in XAML who can guide me better.

Using a UserControl I almost get what I'm looking for but if I try to link the value of a String with a Binding I get the following error;

On the other hand, I can enter a text directly as in the previous property, "Line1", for example. What am I doing wrong?

Thank you very much

    
asked by Edulon 21.10.2018 в 15:29
source

0 answers