对WPF和XAML来说很新.我无法理解为什么我不能在下面的代码中将WPF控件放在我想要的位置.我的问题是<canvas></canvas>标签的位置.我放在这个地方的任何东西都给了我'属性'内容'设置不止一次'
如果有人能用简单的术语解释内容属性设置哪个最有帮助.
我查看了以下文章无济于事: 属性'内容'被多次 设置属性内容被设置多次 属性内容被设置多次 属性'内容'被设置多次按钮WPF ControlTemplate导致错误"属性'内容'设置不止一次"
<Window x:Class="PDFIndexer.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="ParentGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="1*" />
<RowDefinition Height="25" />
</Grid.RowDefinitions>
<Menu Grid.Row="0" >
<MenuItem Header="File" >
<MenuItem Header="Open Project" Click="MenuItem_Click_1"></MenuItem>
<MenuItem Header="Save Project"></MenuItem>
<MenuItem Header="Close Project"></MenuItem>
<Separator></Separator>
<MenuItem Header="Exit"></MenuItem>
</MenuItem>
<MenuItem Header="Edit"></MenuItem>
</Menu>
<TabControl Grid.Row="1">
<TabItem Header="Document Flow" >
This is where the outline of the entire document will be placed.
<Canvas></Canvas>
</TabItem>
<TabItem Header="Preview">
This is where the preview will be drawn to screen.
</TabItem>
<TabItem Header="Resources">
This is where the resources { graphic files, fonts, data files }
</TabItem>
<TabItem Header="Code Library">
This is where the user can save re-usable bits of code. Useful when adding intel barcodes or Address blocks etc...
</TabItem>
</TabControl>
<StatusBar Grid.Row="2">
Items
</StatusBar>
</Grid>
Run Code Online (Sandbox Code Playgroud)
Mar*_*all 40
通过向您TabItem添加的内容添加文本描述,然后在添加Canvas时添加了一个不允许的内容的其他内容项TabItem.你需要使用一个可以容纳一组孩子的控件,比如Canvas,Grid,StackPanel等.尝试这样的事情.
<TabControl Grid.Row="1">
<TabItem Header="Document Flow">
<Canvas>
<TextBlock>
This is where the outline of the entire document will be placed.
</TextBlock>
</Canvas>
</TabItem>
<TabItem Header="Preview">
This is where the preview will be drawn to screen.
</TabItem>
<TabItem Header="Resources">
This is where the resources { graphic files, fonts, data files }
</TabItem>
<TabItem Header="Code Library">
This is where the user can save re-usable bits of code. Useful when adding intel barcodes or Address blocks etc...
</TabItem>
</TabControl>
Run Code Online (Sandbox Code Playgroud)
某些容器只允许1个元素,其他容器允许> 1个元素.当您收到错误消息"内容"被设置多次时,这意味着您已尝试将多种类型的元素放在仅允许1个元素的容器中.
也许尝试这个(未测试):
<TabItem Header="Document Flow" >
<StackPanel>
<TextBlock>This is where the outline of the entire document will be placed. </TextBlock>
<Canvas></Canvas>
</StackPanel>
</TabItem>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
56830 次 |
| 最近记录: |