的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>
代码背后:
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();
}
}
}
因此。我有我的邮件,我已设法在列表视图中显示它们。我想在点击后显示电子邮件的完整内容。要做到这一点,我需要做的事情:
有任何简单的方法吗?