1 Replies - 330 Views - Last Post: 02 February 2013 - 03:59 PM Rate Topic: -----

#1 roshiend  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 26-February 09

WPF Picture and Text for each entry

Posted 02 February 2013 - 03:50 PM

hi,

Is it possible to add picture and the text in to WPF list box like we do on traditional List box for each entry. here I attached my Xmal file and the screen shot of the window.



Posted Image






<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="609">
    <Grid>
        <ListBox Margin="12,12,259,12" HorizontalContentAlignment="Stretch" FontFamily="Verdana" >
            <ListBoxItem Margin=" 0,3,0,3" />
            
            <StackPanel Orientation="Horizontal" Margin=" 3" >
                <Image Source="D:\sun.jpg" Margin=" 3" Height="41" Width="46">
                    
                    
                </Image>
                <TextBlock Margin=" 5 " Padding=" 2" FontSize="13" FontWeight="Bold" Foreground="DarkTurquoise" >sample
                    
                </TextBlock>
                
            </StackPanel>
        </ListBox>
        <Button Content="Add items to List Box" Height="26" HorizontalAlignment="Left" Margin="352,197,0,0" Name="button1" VerticalAlignment="Top" Width="131" />
        <TextBox Height="45" HorizontalAlignment="Left" Margin="352,146,0,0" Name="textBox1" VerticalAlignment="Top" Width="131" />
    </Grid>
</Window>



Is This A Good Question/Topic? 0
  • +

Replies To: WPF Picture and Text for each entry

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5571
  • View blog
  • Posts: 11,910
  • Joined: 02-June 10

Re: WPF Picture and Text for each entry

Posted 02 February 2013 - 03:59 PM

It should be possible.

This looks odd though

Quote

07            <ListBoxItem Margin=" 0,3,0,3" />


You closed the tag for hte listboxitem before putting your stackpanel in it.

I would expect this to be closer:

<ListBoxItem Margin=" 0,3,0,3">
08
09 <StackPanel Orientation="Horizontal" Margin=" 3" >
10 <Image Source="D:\sun.jpg" Margin=" 3" Height="41" Width="46">
11
12
13 </Image>
14 <TextBlock Margin=" 5 " Padding=" 2" FontSize="13" FontWeight="Bold" Foreground="DarkTurquoise" >sample
15
16 </TextBlock>
17
18 </StackPanel>
</Listboxitem>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1