Click here to Skip to main content
15,662,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<Window x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="400">
    <Window.Resources>
        <Style x:Key="xx" TargetType="Label">
            <Setter Property="Opacity" Value=".5"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Label">
                        <StackPanel Orientation="Horizontal">
                            <Image  HorizontalAlignment="Left"
                                    Width="100"
                                    Source="Resources/FldrOpen.png">
                            </Image>
                             
                            <TextBlock Text="aa">
                            </TextBlock>
                        </StackPanel>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
  
    <Grid>  <StackPanel Margin="10,10,10,10">
            <Label 
                Style="{StaticResource xx}"
                Content="Yes Yes" 
                Background="Green" 
                Height="30" 
                Margin="0,0,31,0" />
            </StackPanel>
        <ContentControl Content="ContentControl" HorizontalAlignment="Left" Margin="-455,223,0,0" VerticalAlignment="Top"/>
    </Grid>
</Window>


Hello I have a problem with the following code. I want a label with a image from resources and a textblock. But I don't get the textblock in it.
Posted
Comments
Sergey Alexandrovich Kryukov 24-May-13 17:00pm    
It sounds like a Panel (or a user control) with a TextBlock and an image in it, not a "label"? What's the problem? This must be just the layout...
By the way, if your PNG is not too small, consider using vector graphics XAML object instead.
—SA

Instead of
<textblock text="aa">

You can use <textblock text="aa">
 
Share this answer
 
Comments
quator 24-May-13 17:23pm    
That is not the solution. Only the text "aa" is displayed. The content with "YesYes" should there be displayed.
instead of
HTML
<textblock text="aa">
                           </textblock>

You can use
HTML
<textblock text="aa" />
 
Share this answer
 
v3
Comments
quator 24-May-13 17:23pm    
That is not the solution. Only the text "aa" is displayed. The content with "YesYes" should there be displayed.
Instead of you code as text block in single line use "<TextBlock Text="aa"/>
 
Share this answer
 
Comments
quator 24-May-13 17:23pm    
That is not the solution. Only the text "aa" is displayed. The content with "YesYes" should there be displayed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900