我已经阅读了其他一些答案,但我不能完全理解为什么我的仍然抛出这个错误:
<Grid Grid.Column="2" Width="100" Height="30" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Command="{Binding CloseCommand}" Grid.Column="3" Width="24" Height="24" HorizontalAlignment="Right">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel>
<Image Source="{Binding LocalisedResource[delete_48.png].Image}" Stretch="Fill" VerticalAlignment="Top" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Command="{Binding ShowConfigCommand}" Grid.Column="0" Width="24" Height="24" HorizontalAlignment="Right">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel>
<Image Source="{Binding LocalisedResource[software_24.png].Image}" Stretch="Fill" VerticalAlignment="Top" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
人们没有收到此错误,因此我将发布其余代码:
<Grid>
<Grid.Background>
<SolidColorBrush Color="Black" />
</Grid.Background>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="20" />
</Grid.RowDefinitions>
<TextBlock Text="{Binding LocalisedText[app.title]}" Grid.Column="1" Grid.Row="0" Style="{DynamicResource MainWindowTitleTextStyle}" />
<Grid Grid.Column="2" Width="100" Height="30" HorizontalAlignment="Right">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button Command="{Binding }" Grid.Column="3" Width="24" Height="24" HorizontalAlignment="Right">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel>
<Image Source="{Binding LocalisedResource[delete_48.png].Image}" Stretch="Fill" VerticalAlignment="Top" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Command="{Binding }" Grid.Column="0" Width="24" Height="24" HorizontalAlignment="Right">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<StackPanel>
<Image Source="{Binding LocalisedResource[software_24.png].Image}" Stretch="Fill" VerticalAlignment="Top" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
<!-- Popup Box -->
<ContentPresenter Content="{Binding }" Grid.Column="1" Grid.ColumnSpan="4" Grid.Row="2" Grid.RowSpan="4" VerticalAlignment="Center" HorizontalAlignment="Center" />
<!-- Connected View Goes Here -->
<ContentPresenter Content="{Binding }" Grid.Column="1" Grid.Row="1" />
<!-- Demo View Goes Here -->
<ContentPresenter Content="{Binding }" Grid.Column="1" Grid.Row="2" />
<!-- Configuration -->
<ContentPresenter Content="{Binding }" Grid.ColumnSpan="2" Grid.RowSpan="2" Grid.Row="1" Grid.Column="1" Margin="50" />
</Grid>