void AddText(string message)
{
if (!textbox.CheckAccess())
{
textbox.Dispatcher.Invoke(new Action<string>(AddText), message);
}
else
{
textbox.AppendText(message);
}
}
<ListBox x:Name="lst">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Value}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
lst.ItemsSource = new List<KeyValuePair<int, string>>()
{
new KeyValuePair<int, string>(1, "1"),
new KeyValuePair<int, string>(2, "2"),
};
class MyClass
{
public int id { get; set; }
public string Name { get; set; }
public bool IsChecked { get; set; }
}
<ListBox x:Name="lst">
<ListBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsChecked}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
lst.ItemsSource = new List<MyClass>()
{
new MyClass(){id=1, Name="1"},
new MyClass(){id=2, Name="2"},
};
foreach(var tObj in (lst.ItemsSource as List<MyClass>).Where(myObj => myObj.IsChecked))
MessageBox.Show(tObj.Name);
<ObjectDataProvider x:Key="userDCustom" ObjectType="{x:Type local:UserData}">
<ObjectDataProvider.ConstructorParameters>
<local:User>
<local:User.UserData>
<local.User Name="MyName" />
</local:User.UserData>
</local:User>
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
<Button >
<Run>
<Run.Style>
<Style TargetType="Run">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextDecorations" Value="Underline" />
</Trigger>
</Style.Triggers>
</Style>
</Run.Style>
Текст
</Run>
</Button>
<UserControl x:Class="WpfApplication3.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBox />
<ListBox Grid.Row="1" />
</Grid>
</UserControl>
public MyTextBox : TextBox
{
}
<TextBox x:Class="WpfApplication1.MyTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" >
</TextBox>
//this = currentObject;
//typeof(this) == typeof(Reader);
var indexBinding = new Binding();
indexBinding.Mode = BindingMode.TwoWay;
//указываю подчненный контролл как источник данных
indexBinding.ElementName = "epubConrol";
indexBinding.Path = new PropertyPath("SelectedIndex");
//Очищаю свойство зависимостей и создаю привязку
currentObject.ClearValue(Reader.SelectedIndexProperty);
currentObject.SetBinding(Reader.SelectedIndexProperty, indexBinding);
<ListBox x:Name="lst1" SelectedIndex="{Binding ElementName=lst2, Path=SelectedIndex, Mode=TwoWay}">
<system:String>1 строка</system:String>
<system:String>2 строка</system:String>
</ListBox>
<ListBox Grid.Column="1" x:Name="lst2">
<system:String>1 строка</system:String>
<system:String>2 строка</system:String>
</ListBox>
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ItemsControl x:Name="itemsData">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl BorderBrush="Black" BorderThickness="1" ItemsSource="{Binding}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<ItemsControl BorderBrush="Black" BorderThickness="1" ItemsSource="{Binding}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=.}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Window>
namespace WpfApplication1
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
var my = new MyClass();
my.Data = new List<byte[][]>();
my.Data.Add(new byte[][] { new byte[] { 0, 1 }, new byte[] { 2, 3 }, new byte[] { 4, 5 } });
my.Data.Add(new byte[][] { new byte[] { 6, 7 }, new byte[] { 8, 9 }, new byte[] { 10, 11 } });
itemsData.ItemsSource = my.Data;
}
}
public class MyClass
{
public List<byte[][]> Data
{ get; set; }
}
}
<ScrollViewer VerticalScrollBarVisibility="Auto" IsHitTestVisible="False" >
<TextBlock TextWrapping="Wrap" Text="{Binding FirstInformation}"/>
</ScrollViewer>
<ScrollViewer VerticalScrollBarVisibility="Auto" >
<TextBlock TextWrapping="Wrap" Text="{Binding FirstInformation}" MouseLeftButtonUp="TextBlock_MouseLeftButtonUp"/>
</ScrollViewer>
private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
var tb = sender as TextBlock;
// Нужно дополнительно обложиться проверками, что типы совпадают
((tb.Parent as ScrollViewer).Parent as RadioButton).IsChecked = true;
}
Navigate(new Page2(){ variable = "abc"});
void goButton_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new ContentPage(), DateTime.Now);
}
void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
{
DateTime requestDateTime = (DateTime)e.ExtraData;
string msg = string.Format("Request started {0}\nRequest completed {1}", requestDateTime, DateTime.Now);
MessageBox.Show(msg);
}
tProfiler.ItemsSource = queryInf;
<Canvas>
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathFigure>
<LineSegment Point="100,100"/>
<LineSegment Point="150,120"/>
<PolyBezierSegment Points="170,120 190,100 200,160 220,140"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
</Canvas>