我正在尝试制作一个有条件的表格 选择服务器类型的位置,在该值上,字段会更改。 但问题是我启动这个WPF应用程序的那一刻。我的应用程序进入休息模式。但我不知道他进入休息模式的地点或原因。
我评论2个网格时,应用程序启动没有问题。但是一旦我取消注释这些网格,WPF应用就会失败。
这是XAML
<Grid Margin="0,0,0,5" Grid.Row="7" Grid.ColumnSpan="2" Background="Yellow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Label Grid.ColumnSpan="2" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold" Content="Server settings" />
<Label Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" FontWeight="Bold" Content="Server type:" />
<ComboBox Name="ServerTypCmbx" Grid.Row="1" Grid.Column="1" SelectionChanged="ServerTypCmbx_SelectionChanged"></ComboBox>
<StackPanel Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Grid.RowSpan="3">
<Grid Visibility="Hidden" Name="S7Grid" Background="Purple">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Ip:" />
<TextBox Text="{Binding Path=ServerSetting.Ip}" Margin="0,1" Grid.Row="0" Grid.Column="1"></TextBox>
<Label Grid.Row="1" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Rack:" />
<TextBox Text="{Binding Path=ServerSetting.Rack}" Margin="0,1" Grid.Row="1" Grid.Column="1"></TextBox>
<Label Grid.Row="2" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Slot:" />
<TextBox Text="{Binding Path=ServerSetting.Slot}" Margin="0,1" Grid.Row="2" Grid.Column="1"></TextBox>
</Grid >
<Grid Visibility="Hidden" Name="OPC_UAGrid" Background="Purple">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Adress:" />
<TextBox Text="{Binding Path=ServerSetting.Adress}" Margin="0,1" Grid.Row="0" Grid.Column="1"></TextBox>
<Label Grid.Row="1" HorizontalAlignment="Center" FontWeight="Bold" Content="Server NameUri:" />
<TextBox Text="{Binding Path=ServerSetting.NamespaceUri}" Margin="0,1" Grid.Row="1" Grid.Column="1"></TextBox>
<Label Grid.Row="2" HorizontalAlignment="Center" FontWeight="Bold" Content="Server NameIndex:" />
<TextBox Text="{Binding Path=ServerSetting.NameSpaceIndex}" Margin="0,1" Grid.Row="2" Grid.Column="1"></TextBox>
</Grid>
<Grid Visibility="Hidden" Name="OPC_DAGrid" Background="Purple">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="30" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<Label Grid.Row="0" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Adress:" />
<TextBox Text="{Binding Path=ServerSetting.Adress}" Margin="0,1" Grid.Row="0" Grid.Column="1"></TextBox>
<Label Grid.Row="1" HorizontalAlignment="Center" FontWeight="Bold" Content="Server Name:" />
<TextBox Text="{Binding Path=ServerSetting.Name}" Margin="0,1" Grid.Row="1" Grid.Column="1"></TextBox>
</Grid>
</StackPanel>
</Grid>
答案 0 :(得分:0)
我找到了解决方案。
在输出窗口中,您可以看到它从演示文稿dll中发出错误 它不能在一个属性上绑定一个或两个方式。该属性是私有集
之前:
public string Adress { get; private set; }
public string NamespaceUri { get; private set; }
public ushort NameSpaceIndex { get; private set; }
之后
public string Adress { get; set; }
public string NamespaceUri { get; set; }
public ushort NameSpaceIndex { get; set; }