【发布时间】:2017-09-04 10:44:14
【问题描述】:
我从 wpf 开始,我想使用静态资源,当我添加标签时出现错误:属性 Content 只能设置一次,现在当我在 stackoverflow 上搜索时,我了解到窗口标签可以只有一个子元素,在我正在阅读的书上,静态资源标签就在网格标签上方,这是如何工作的?这是我的代码:
<Window x:Class="BaseBallSimulator.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-compatibilit/2006"
xmlns:local="clr-namespace:BaseBallSimulator"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525" >
<StaticResource></StaticResource>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="245*"/>
<ColumnDefinition Width="272*"/>
</Grid.ColumnDefinitions>
<StackPanel>
<StackPanel Margin="10">
<TextBlock Text="Trajectory"></TextBlock>
<TextBox Name="TrajectoryTextBox" Text="0" Margin="0,5,0,0" Height="20"></TextBox>
</StackPanel>
<StackPanel Margin="10">
<TextBlock Text="Distance"></TextBlock>
<TextBox Name="DistanceTextBox" Text="0" Margin="0,5,0,0" Height="20"></TextBox>
</StackPanel>
<Button Name="PlayButton" Content="PRESS To PLAY" Margin="10" Click="PlayButton_Click" ></Button>
</StackPanel>
<StackPanel Grid.Column="1">
<StackPanel Margin="5">
<TextBlock Text="Pitcher Says" Margin="5"/>
<ListView x:Name="PitcherSaysListView" Margin="5" Height="110" />
</StackPanel>
<StackPanel Margin="5,0,5,5">
<TextBlock Text="Fan Says" Margin="5"/>
<ListView x:Name="FanSaysListView" Margin="5" Height="110" />
</StackPanel>
</StackPanel>
</Grid>
</Window>
【问题讨论】:
-
你为什么要添加
?删除它,它就可以工作了...... -
是的,我知道它可以工作,但我需要一个该标签来设置静态资源,否则怎么办?