public int Age
{
get { return age; }
set
{
age = value;
OnPropertyChanged("Price");
}
}
public int Age
{
get { return age; }
set
{
age = value;
OnPropertyChanged("Age");
}
}
string res=Properties.Resources.Data_XMLFile;
XmlReader xml2 = XmlReader.Create(new StringReader(res));
Uri uri = new Uri("pack://application:,,,/Resources/Data_XMLFile.xml", UriKind.Absolute);
StreamResourceInfo info = Application.GetResourceStream(uri);
XmlReader xml = XmlReader.Create(info.Stream);
<Window x:Class="WpfApp1.MainWindow"
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:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800" Loaded="Window_Loaded" >
<Grid>
<ListBox x:Name="listbox1" DisplayMemberPath="Name">
</ListBox>
</Grid>
</Window>
public partial class MainWindow : Window
{
private MainViewModel viewModel = new MainViewModel();
public MainWindow()
{
InitializeComponent();
//добавляем сотрудников
viewModel.Employees.Add(new Employee() {Name="Иванов Иван" });
viewModel.Employees.Add(new Employee() { Name = "Петров Петр" });
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
//привязываем viewModel (необязательно для отображения списка)
this.DataContext = viewModel;
//привязываем коллекцию
this.listbox1.ItemsSource = viewModel.Employees;
}
}
var yourObject=DGPrinterViev.SelectedItem as <ваш тип>;
if(yourObject!=null)
{
int id=yourObject.SeriyNomerPrinter;//либо как называется нужное свойство
}
<Window.Resources>
<!--шаблон кнопки-->
<ControlTemplate x:Key="buttonTemplate1" TargetType="{x:Type Button}">
<Border Name="border" BorderBrush="Black" BorderThickness="1" CornerRadius="0" Background="Red" TextBlock.Foreground="Black">
<Grid>
<Rectangle Name="focusCue" Visibility="Hidden" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2" SnapsToDevicePixels="True"></Rectangle>
<ContentPresenter Margin="{TemplateBinding Padding}" HorizontalAlignment="Center" RecognizesAccessKey="True"></ContentPresenter>
</Grid>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Background.Color" To="Purple" >
</ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetName="border" Storyboard.TargetProperty="Background.Color" >
</ColorAnimation>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="border" Property="Background" Value="IndianRed"></Setter>
<Setter TargetName="border" Property="BorderBrush" Value="DarkKhaki"></Setter>
</Trigger>
<Trigger Property="IsFocused" Value="true">
<Setter TargetName="focusCue" Property="Visibility" Value="Visible"></Setter>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter TargetName="border" Property="TextBlock.Foreground" Value="Gray"></Setter>
<Setter TargetName="border" Property="Background" Value="MistyRose"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="newButtonStyle" TargetType="Button">
<Setter Property="Control.Template" Value="{StaticResource buttonTemplate1}"></Setter>
</Style>
</Window.Resources>
<StackPanel>
<Button Height="30" Width="100" Margin="10" Style="{StaticResource newButtonStyle}">
</Button>
</StackPanel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Modules"/>
</assemblyBinding>
</runtime>