0

Xaml:

<Window x:Class="Berichtensysteem.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:Berichtensysteem"
            mc:Ignorable="d"
            Title="Mailclient" Height="800" Width="800"
            >

        <Grid>

            <UserControl>
                <Grid Margin="0,-10,177,10">
                    <Button x:Name="inboxClick" Content="Inbox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="121" Margin="1,56,0,0"/>
                    <Button x:Name="outbox" Content="Verzonden berichten" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" Margin="1,96,0,0"/>
                    <Button x:Name="deleted" Content="Verwijderde berichten" HorizontalAlignment="Left" VerticalAlignment="Top" Width="121" Margin="1,76,0,0"/>

                </Grid>
            </UserControl>


            <ListView Margin="126,45,0,0" Name="inbox">
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="From" Width="70" DisplayMemberBinding="{Binding from}" />
                        <GridViewColumn Header="Subject" Width="120" DisplayMemberBinding="{Binding subject}" />
                        <GridViewColumn Header="Content" Width="150" DisplayMemberBinding="{Binding content}" />
                    </GridView>
                </ListView.View>
            </ListView>
        </Grid>
    </Window>

Code behind:

    public partial class Window1 : Window
    {
        private static databaselinkDataContext _dataDC = new databaselinkDataContext();
        public Window1(String username)
        {
            InitializeComponent();
            sendMail();



            List<email> _mails = _dataDC.emails.ToList();
            inbox.ItemsSource = _mails;

        }

// Adding an email to the database because I haven't set up send mails yet.

        public void sendMail()
        {
            var _email = new email();
            _email.content = "Mijn inhoud";
            _email.from = "hallo";
            _email.subject = "myemailsubject";
            _email.layout = "";

            _dataDC.emails.InsertOnSubmit(_email);
            _dataDC.SubmitChanges();
        }
    }
}

So. I have my mails, I've managed to display them on the screen with a listview. I want to show the full content of the e-mail once it is clicked. To do this I need to things:

  1. Add a click listener to each listview item (similar to recyclerview in android?).
  2. Replace the listview with the contents of the email, while maintaining my usecontrol.

Any simple way to do this?

user3117628
  • 776
  • 1
  • 15
  • 35

1 Answers1

0
  1. As an option add event listener PreviewMouseLeftButtonUp:
<ListView Name="inbox" PreviewMouseLeftButtonUp="Inbox_OnPreviewMouseLeftButtonUp">
  1. Your second suggestion is not clear. Implementation depends on what result and behavior you want to achieve. If you want to temporary change listView items interface style, you can change its style programmatically. But since then, how user can change its appearance back? That's not an obvious behavior.

Another option: to use DataTemplate with expander(customize ListItem element), where you can show or hide additional email information (example). Or you can show on ListItem click a new window, right above listItems area(example)

Community
  • 1
  • 1
Fragment
  • 1,555
  • 1
  • 26
  • 33