我有一个名为"DataEntryForm"
和2 UserControls
"Identification"
和"SamplingInformation"
的主窗口,它们作为选项卡嵌入在主窗口中。
我有一个名为Report的对象,该对象在"Identification"
UserControl中调用
我需要将报表对象绑定/调用/传递给"SamplingInformation"
UserControl
<Window x:Class="Frontend_WPF.Forms.DataEntryForm"
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:Frontend_WPF.Forms.User_Controls"
mc:Ignorable="d"
Title="Data Entry" Width="800" Height="600" WindowStartupLocation="CenterScreen" WindowState="Maximized" WindowStyle="SingleBorderWindow" >
<Viewbox Stretch="Fill" Margin="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="695*" />
</Grid.RowDefinitions>
<Viewbox Stretch="Fill">
<TabControl HorizontalAlignment="Left" Name="TabControl" VerticalAlignment="Top" Grid.RowSpan="1" >
<TabItem Name="ID">
<TabItem.Header>
<TextBlock Name="IDHeader" Text="ID"
ToolTip="IDENTIFICATION"/>
</TabItem.Header>
<Grid>
<local:Identification x:Name="Identification_UC" />
</Grid>
</TabItem>
<TabItem Name="SamplingInformation">
<TabItem.Header>
<TextBlock Name="SIHeader" Text="SAMPLING INFORMATION"
ToolTip="SAMPLING INFORMATION"/>
</TabItem.Header>
<Grid>
<local:SamplingInformation x:Name="SamplingInformation_UC" />
</Grid>
</TabItem>
</Viewbox>
</Grid>
</Viewbox >
我的对象
public class Report{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "code")]
public string Code { get; set; }
[JsonProperty(PropertyName = "date")]
public DateTime date{ get; set; }
[JsonProperty(PropertyName = "SamplingInfo")]
public SamplingInfo samplingInfo { get; set; }
}
public class SamplingInfo
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "Name")]
public string name { get; set; }
[JsonProperty(PropertyName = "type")]
public string type { get; set; }
}
我可以传递对象并在“ SamplingInformation” UserControl中使用它,还是可以将其直接绑定到它?