Click here to Skip to main content
15,888,984 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF performance on Windows XP Pin
Gerry Schmitz2-Apr-13 13:45
mveGerry Schmitz2-Apr-13 13:45 
AnswerRe: WPF performance on Windows XP Pin
Pete O'Hanlon2-Apr-13 12:09
mvePete O'Hanlon2-Apr-13 12:09 
QuestionComboBox in a DataGrid, Binding Problem Pin
shakilahmad1232-Apr-13 1:23
shakilahmad1232-Apr-13 1:23 
QuestionHello All. Pin
caradri1-Apr-13 23:08
caradri1-Apr-13 23:08 
AnswerRe: Hello All. Pin
Kenneth Haugland2-Apr-13 9:21
mvaKenneth Haugland2-Apr-13 9:21 
QuestionData display issue with combo box in wpf data grid Pin
ukraju1-Apr-13 7:31
ukraju1-Apr-13 7:31 
AnswerRe: Data display issue with combo box in wpf data grid Pin
Richard MacCutchan1-Apr-13 21:48
mveRichard MacCutchan1-Apr-13 21:48 
QuestionGet File Path from ListView Pin
MumbleB31-Mar-13 3:44
MumbleB31-Mar-13 3:44 
Hi Guys, I have a nice working app in Windows Forms. I am attempting to port it to WPF and I am stuck with selecting a row and getting a value from one of the columns.

Apologies for the long code:

In Windows Forms App I do the below:

C#
private void lstFiles_DoubleClick(object sender, EventArgs e)
{
    if (lstFiles.SelectedItems.Count != 0)
    {
        string file = lstFiles.SelectedItems[0].Text;
        openFormGeneral(file);
    }
}


In WPF .xaml:

<ListView x:Name="lstFile" Height="357" HorizontalAlignment="Left" Margin="18,144,0,0" VerticalAlignment="Top" Width="550"
          ItemsSource="{Binding songDetails}"
          MouseDoubleClick="lstFile_MouseDoubleClick"
          IsSynchronizedWithCurrentItem="True"
          SelectedItem="{Binding Path=SelectedSong}">
    <ListView.View>
        <GridView>
            <GridViewColumn CellTemplate="{StaticResource FirstCell}" Width="30" />
            <GridViewColumn Header="File Name" DisplayMemberBinding="{Binding FileName}" />
            <GridViewColumn Header="Title" DisplayMemberBinding="{Binding Title}" />
            <GridViewColumn Header="Artist" DisplayMemberBinding="{Binding Artist}" />
            <GridViewColumn Header="Album" DisplayMemberBinding="{Binding Album}" />
            <GridViewColumn Header="Set" DisplayMemberBinding="{Binding Set}" />
            <GridViewColumn Header="Genre" DisplayMemberBinding="{Binding Genre}" />
            <GridViewColumn Header="Language" DisplayMemberBinding="{Binding Language}" />
            <GridViewColumn Header="File Path" DisplayMemberBinding="{Binding FilePath}" />
        </GridView>
    </ListView.View>
</ListView>


I Populate the ListView as follows:

public class songDetails
{
public string Title { get; set; }
public string Artist { get; set; }
public string Track { get; set; }
public string Set { get; set; }
public string Album { get; set; }
public string Genre { get; set; }
public string Language { get; set; }
public string FileName { get; set; }
public string FilePath { get; set; }
}

public IList<songDetails> songDetail { get; set; }


public void AddFile(ID3Info File)
{
    lstFile.Items.Add(new
    {
        FileName = File.FileName,
        Artist = File.ID3v2Info.GetTextFrame("TPE1"),
        Title = File.ID3v2Info.GetTextFrame("TIT2"),
        Track = File.ID3v2Info.GetTextFrame("TRCK"),
        Album = File.ID3v2Info.GetTextFrame("TALB"),
        Genre = File.ID3v2Info.GetTextFrame("TCON"),
        Language = File.ID3v2Info.GetTextFrame("TLAN"),
        FilePath = File.FilePath
    });

    artist = File.ID3v2Info.GetTextFrame("TPE1");
    track = File.ID3v2Info.GetTextFrame("TRCK");
    set = File.ID3v2Info.GetTextFrame("TPOS");
    title = File.ID3v2Info.GetTextFrame("TIT2");
    album = File.ID3v2Info.GetTextFrame("TALB");
    genre = File.ID3v2Info.GetTextFrame("TCON");
    language = File.ID3v2Info.GetTextFrame("TLAN");

    InitializeComponent();
    this.DataContext = this;
}

How do I access the FilePath from the ListView with MouseDoubleClick event? Thanks in advance
Excellence is doing ordinary things extraordinarily well.

AnswerRe: Get File Path from ListView Pin
Mycroft Holmes31-Mar-13 12:39
professionalMycroft Holmes31-Mar-13 12:39 
GeneralRe: Get File Path from ListView Pin
MumbleB1-Apr-13 0:34
MumbleB1-Apr-13 0:34 
GeneralRe: Get File Path from ListView Pin
Mycroft Holmes1-Apr-13 1:23
professionalMycroft Holmes1-Apr-13 1:23 
GeneralRe: Get File Path from ListView Pin
MumbleB2-Apr-13 9:10
MumbleB2-Apr-13 9:10 
GeneralRe: Get File Path from ListView Pin
Mycroft Holmes2-Apr-13 12:15
professionalMycroft Holmes2-Apr-13 12:15 
GeneralRe: Get File Path from ListView Pin
MumbleB3-Apr-13 7:27
MumbleB3-Apr-13 7:27 
QuestionCollection of User Controls Pin
Mycroft Holmes30-Mar-13 22:44
professionalMycroft Holmes30-Mar-13 22:44 
AnswerRe: Collection of User Controls Pin
SledgeHammer0131-Mar-13 14:48
SledgeHammer0131-Mar-13 14:48 
GeneralRe: Collection of User Controls Pin
Mycroft Holmes31-Mar-13 14:55
professionalMycroft Holmes31-Mar-13 14:55 
GeneralRe: Collection of User Controls Pin
SledgeHammer0131-Mar-13 15:13
SledgeHammer0131-Mar-13 15:13 
GeneralRe: Collection of User Controls Pin
Mycroft Holmes31-Mar-13 15:30
professionalMycroft Holmes31-Mar-13 15:30 
GeneralRe: Collection of User Controls Pin
SledgeHammer0131-Mar-13 15:43
SledgeHammer0131-Mar-13 15:43 
GeneralRe: Collection of User Controls Pin
Mycroft Holmes31-Mar-13 15:59
professionalMycroft Holmes31-Mar-13 15:59 
GeneralRe: Collection of User Controls Pin
SledgeHammer0131-Mar-13 16:20
SledgeHammer0131-Mar-13 16:20 
GeneralRe: Collection of User Controls Pin
Mycroft Holmes31-Mar-13 18:02
professionalMycroft Holmes31-Mar-13 18:02 
QuestionWPF ComboBox With User Control Pin
Kevin Marois30-Mar-13 10:24
professionalKevin Marois30-Mar-13 10:24 
AnswerRe: WPF ComboBox With User Control(This may not work.) Pin
David C# Hobbyist.30-Mar-13 10:52
professionalDavid C# Hobbyist.30-Mar-13 10:52 

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.