public class Card
{
public int CardId { set; get; }
public Record Record { set; get; }
}
public class Record
{
public int RecordId { set; get; }
}
modelBuilder.Entity<Card>()
.HasRequired(x => x.Record)
.WithRequiredPrincipal()
.WillCascadeOnDelete(false);
db.Switchers.AddOrUpdate(switcher);
db.SaveChanges();
db.Entry(switcher).State = EntityState.Modified;
db.SaveChanges();
public class Theme
{
public int ThemeId { get; set; }
public DateTime? ThemeDate { get; set; }
public string ThemeName { get; set; }
public string ThemeDes { get; set; }
public virtual User User { get; set; }
//public int UserId { get; set; }
public virtual ICollection<ForumMessage> FMessage { get; set; }
}
{Binding Seminares, Mode=TwoWay}
<Window
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" mc:Ignorable="d" x:Class="WpfApplication1.MainWindow"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ListView ItemsSource="{Binding ExampleList}">
<ListView.Resources>
<DataTemplate x:Key="DataTemplatePBar">
<ProgressBar Value="{Binding PBarValue}" IsIndeterminate="False" Width="100" Height="20"/>
</DataTemplate>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Text}"/>
<GridViewColumn Header="ProgressBar" CellTemplate="{DynamicResource DataTemplatePBar}"/>
<GridViewColumn Header="Button">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Button Content="{Binding ButtonText}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
public class MainViewModel
{
public List<ExampleItem> ExampleList { get; set; }
public MainViewModel()
{
this.ExampleList = new List<ExampleItem>();
Populate();
}
public void Populate()
{
for (int i = 1; i <= 5; i++)
{
ExampleList.Add(new ExampleItem { Text = "Example" + i, PBarValue = 10*i,ButtonText = "Button " + i});
}
}
}
public class ExampleItem
{
public string Text { get; set; }
public int PBarValue { get; set; }
public string ButtonText { get; set; }
}
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MainViewModel main = new MainViewModel();
MainWindow window = new MainWindow
{
DataContext = main
};
window.Show();
}
}