public class Worker
{
public string FIO {get;set;}
public SpanTime WorkTime {get;set;}
}
<ListBox x:Name="lst">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox Text="{Binding FIO}" />
<TextBox Text="{Binding WorkTime}" Grid.Column="1"/>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
lst.ItemSource = new List<Worker>() {new Worker(){FIO = "Иванов"}, new Worker(){FIO = "Петров"}};
<TreeView>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Path=product}">
<TextBlock Text="{Binding} />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<HierarchicalDataTemplate DataType="{x:type l:product}">...
class Item
{
public string Name {get;set;}
public IEnumerable<Item> Children
{
get {/* тут код получения из базы подчинённых элементов*/}
}
}
<TreeView>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
var line = reader.ReadLine();
var words = line.Split(" ".ToCharArray()).ToList();
words.RemoveAt(4);
var result = string.Join(" ", words);
<Window ...>
<Window.DataContext>
<game:Game/>
</Window.DataContext>
<StackPanel>
<local:MageControl DataContext="{Binding Red}"/> <!-- привязка к DataContext отлично работает -->
<local:MageControl DataContext="{Binding Blue}" Turn="{Binding Turn}"/> <!-- привязка к Turn не работает! -->
</StackPanel>
</Window>
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
A test = new A();
Console.WriteLine(test.bPart.testMethod());
Console.ReadLine();
}
}
class A
{
public B bPart = new B();
public class B
{
private string testB = "I'm test in class B";
public string testMethod ()
{
return testB;
}
}
}
}