Click here to Skip to main content
15,896,726 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: how to bind images horizontally in datagrid Pin
Jagz W31-Dec-09 17:06
professionalJagz W31-Dec-09 17:06 
GeneralRe: how to bind images horizontally in datagrid Pin
Mark Salsbery31-Dec-09 17:10
Mark Salsbery31-Dec-09 17:10 
GeneralRe: how to bind images horizontally in datagrid Pin
Jagz W31-Dec-09 19:01
professionalJagz W31-Dec-09 19:01 
GeneralRe: how to bind images horizontally in datagrid Pin
Mark Salsbery1-Jan-10 8:57
Mark Salsbery1-Jan-10 8:57 
GeneralMessage Removed Pin
30-Dec-09 14:27
user20530-Dec-09 14:27 
GeneralRe: Looking for C++/C#/WPF expert Pin
AspDotNetDev30-Dec-09 22:11
protectorAspDotNetDev30-Dec-09 22:11 
QuestionUsing ListViewItem in WPF ? Pin
Mohammad Dayyan30-Dec-09 9:03
Mohammad Dayyan30-Dec-09 9:03 
AnswerRe: Using ListViewItem in WPF ? Pin
AspDotNetDev30-Dec-09 22:53
protectorAspDotNetDev30-Dec-09 22:53 
First, create a class that holds 3 properties:
C#
using System.Windows;
namespace WpfApplication1
{
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();
		}
	}
<big><big><big>	public class MyClass
	{
		public string Prop1
		{
			get;
			set;
		}
		public string Prop2
		{
			get;
			set;
		}
		public string Prop3
		{
			get;
			set;
		}
	}</big></big></big>
}

Next, you can define an array in your XAML then set that as your ItemsSource on your ListView. Then you use the DisplayMemberBinding property of each GridViewColumn to decide what you want to display in each column:
XML
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
<big><big><big>    xmlns:local="clr-namespace:WpfApplication1"</big></big></big>>
<big><big><big>    <Window.Resources>
        <x:Array x:Key="SomeData" Type="{x:Type local:MyClass}">
            <local:MyClass Prop1="test1" Prop2="test2" Prop3="test3" />
            <local:MyClass Prop1="test4" Prop2="test5" Prop3="test6" />
            <local:MyClass Prop1="test7" Prop2="test8" Prop3="test9" />
            <local:MyClass Prop1="test10" />
        </x:Array>
    </Window.Resources></big></big></big>
    <Grid>
        <ListView <big><big><big>ItemsSource="{StaticResource SomeData}"</big></big></big>>
            <ListView.View>
                <GridView>
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop1}"</big></big></big> Header="Name" Width="50" />
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop2}"</big></big></big> Header="Tags" Width="50" />
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop3}"</big></big></big> Header="Location" Width="50" />
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</Window>

If you REALLY want to specify each ListViewItem rather than setting the ItemsSource, then you could use this XAML instead:
XML
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfApplication1">
    <Grid>
        <ListView>
            <ListView.View>
                <GridView>
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop1}"</big></big></big> Header="Name" Width="50" />
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop2}"</big></big></big> Header="Tags" Width="50" />
                    <GridViewColumn <big><big><big>DisplayMemberBinding="{Binding Prop3}"</big></big></big> Header="Location" Width="50" />
                </GridView>
            </ListView.View>
            <ListViewItem><big><big><big><local:MyClass Prop1="test1" Prop2="test2" Prop3="test3" /></big></big></big></ListViewItem>
            <ListViewItem><big><big><big><local:MyClass Prop1="test4" Prop2="test5" Prop3="test6" /></big></big></big></ListViewItem>
            <ListViewItem><big><big><big><local:MyClass Prop1="test7" Prop2="test8" Prop3="test9" /></big></big></big></ListViewItem>
            <ListViewItem><big><big><big><local:MyClass Prop1="test10" /></big></big></big></ListViewItem>
        </ListView>
    </Grid>
</Window>



GeneralRe: Using ListViewItem in WPF ? [modified] Pin
Mohammad Dayyan31-Dec-09 21:02
Mohammad Dayyan31-Dec-09 21:02 
GeneralRe: Using ListViewItem in WPF ? Pin
AspDotNetDev1-Jan-10 1:46
protectorAspDotNetDev1-Jan-10 1:46 
GeneralRe: Using ListViewItem in WPF ? Pin
Mohammad Dayyan1-Jan-10 6:08
Mohammad Dayyan1-Jan-10 6:08 
QuestionGetting click location Pin
Jeroen De Dauw30-Dec-09 5:44
Jeroen De Dauw30-Dec-09 5:44 
AnswerRe: Getting click location Pin
ProtoBytes30-Dec-09 6:47
ProtoBytes30-Dec-09 6:47 
AnswerRe: Getting click location Pin
Mark Salsbery30-Dec-09 7:18
Mark Salsbery30-Dec-09 7:18 
AnswerRe: Getting click location Pin
Jeroen De Dauw30-Dec-09 9:37
Jeroen De Dauw30-Dec-09 9:37 
AnswerRe: Getting click location Pin
Jeroen De Dauw30-Dec-09 12:00
Jeroen De Dauw30-Dec-09 12:00 
GeneralRe: Getting click location Pin
Jeroen De Dauw31-Dec-09 7:52
Jeroen De Dauw31-Dec-09 7:52 
QuestionSilverlight ComboBox Binding Issue [modified] Pin
Programm3r30-Dec-09 2:18
Programm3r30-Dec-09 2:18 
AnswerRe: Silverlight ComboBox Binding Issue Pin
MikeGoatly3-Sep-10 5:14
MikeGoatly3-Sep-10 5:14 
QuestionWndProc equivalent in WPF? Pin
pbalaga29-Dec-09 10:41
pbalaga29-Dec-09 10:41 
GeneralRe: WndProc equivalent in WPF? Pin
ProtoBytes29-Dec-09 11:23
ProtoBytes29-Dec-09 11:23 
AnswerRe: WndProc equivalent in WPF? Pin
teejayem29-Dec-09 12:20
teejayem29-Dec-09 12:20 
GeneralRe: WndProc equivalent in WPF? Pin
pbalaga29-Dec-09 23:12
pbalaga29-Dec-09 23:12 
Questionwhy Scrollviewer clip content in wpf Pin
wasimsharp28-Dec-09 23:08
wasimsharp28-Dec-09 23:08 
AnswerRe: why Scrollviewer clip content in wpf Pin
Mark Salsbery29-Dec-09 10:26
Mark Salsbery29-Dec-09 10:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.