<Window x:Class="ClientSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pHmiControls="clr-namespace:PHmiClient.Controls;assembly=PHmiClient" Title="MainWindow" Height="350" Width="525"> <Grid> <pHmiControls:Root/> </Grid> </Window>
<Window x:Class="ClientSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pHmiControls="clr-namespace:PHmiClient.Controls;assembly=PHmiClient" xmlns:clientSample="clr-namespace:ClientSample" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <clientSample:PHmi x:Key="PHmi"/> </Window.Resources> <Grid> <pHmiControls:Root DataContext="{StaticResource PHmi}"/> </Grid> </Window>
using PHmiClient.Controls.Pages; using System; using System.Windows.Controls; namespace ClientSample.Pages { /// <summary> /// Interaction logic for HomePage.xaml /// </summary> public partial class HomePage : UserControl, IPage { public HomePage() { InitializeComponent(); } public object PageName { get { return "Home page"; } } public PHmiClient.Controls.IRoot Root { get; set; } } }
<UserControl x:Class="ClientSample.Pages.HomePage" 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" xmlns:clientSample="clr-namespace:ClientSample" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance clientSample:PHmi, IsDesignTimeCreatable=True}"> <Grid> <StackPanel> <TextBlock Text="{Binding Path=IoDev.DigitalTag.Value}"/> <TextBlock Text="{Binding Path=IoDev.NumericTag.ValueString}"/> </StackPanel> </Grid> </UserControl>
<Window x:Class="ClientSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:pHmiControls="clr-namespace:PHmiClient.Controls;assembly=PHmiClient" xmlns:clientSample="clr-namespace:ClientSample" xmlns:pages="clr-namespace:ClientSample.Pages" Title="MainWindow" Height="350" Width="525"> <Window.Resources> <clientSample:PHmi x:Key="PHmi"/> </Window.Resources> <Grid> <pHmiControls:Root DataContext="{StaticResource PHmi}" HomePage="{x:Type pages:HomePage}"/> </Grid> </Window>
<UserControl x:Class="ClientSample.Pages.HomePage" 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" xmlns:clientSample="clr-namespace:ClientSample" xmlns:pHmiControls="clr-namespace:PHmiClient.Controls;assembly=PHmiClient" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance clientSample:PHmi, IsDesignTimeCreatable=True}"> <Grid> <StackPanel> <TextBlock Text="{Binding Path=IoDev.DigitalTag.Value}"/> <TextBlock Text="{Binding Path=IoDev.NumericTag.ValueString}"/> <CheckBox IsChecked="{Binding Path=IoDev.DigitalTag.Value, Mode=TwoWay}" Content="{Binding Path=IoDev.DigitalTag.Description}"/> <pHmiControls:NumericInput NumericTag="{Binding Path=IoDev.NumericTag}"/> </StackPanel> </Grid> </UserControl>
<UserControl x:Class="ClientSample.Pages.HomePage" 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" xmlns:clientSample="clr-namespace:ClientSample" xmlns:pHmiControls="clr-namespace:PHmiClient.Controls;assembly=PHmiClient" xmlns:trends="clr-namespace:PHmiClient.Controls.Trends;assembly=PHmiClient" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance clientSample:PHmi, IsDesignTimeCreatable=True}"> <Grid> <StackPanel> <TextBlock Text="{Binding Path=IoDev.DigitalTag.Value}"/> <TextBlock Text="{Binding Path=IoDev.NumericTag.ValueString}"/> <CheckBox IsChecked="{Binding Path=IoDev.DigitalTag.Value, Mode=TwoWay}" Content="{Binding Path=IoDev.DigitalTag.Description}"/> <pHmiControls:NumericInput NumericTag="{Binding Path=IoDev.NumericTag}"/> <trends:TrendViewer Height="400"> <trends:TrendPen TrendTag="{Binding Path=Trends.NumericTagTrend}" Brush="Red"/> </trends:TrendViewer> </StackPanel> </Grid> </UserControl>
using System.Threading; using System.Windows; using System.Windows.Markup; namespace ClientSample { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { Language = XmlLanguage.GetLanguage( Thread.CurrentThread.CurrentUICulture.IetfLanguageTag); InitializeComponent(); } } }
Source: https://habr.com/ru/post/248423/
All Articles