我最近从 VS2010 切换到 Visual Studio 2012。我有一些用户控件,它们是其他用户控件的模板。第一个有一些 ContentControl,其内容在第二个中定义。
遵循基于模板控件(ImpegniBaseView)的用户控件定义
<localView:ImpegniBaseView>
<localView:ImpegniBaseView.ActionButtons>
<StackPanel Height="54" HorizontalAlignment="Left" VerticalAlignment="Top" Width="668" Orientation="Horizontal">
<Button Content="Salva" Height="31" Width="88" Command="{Binding Path=SaveCommand}" IsEnabled="{Binding Editable}" Margin="5,0" />
<Button Command="{Binding Path=CreateCommand}" Content="Nuovo impegno master" Height="31" Width="Auto"
Visibility="{Binding IsFirstLevelView, Converter={StaticResource BoolToVisibility}}"
IsEnabled="{Binding Path=Editable, Converter={StaticResource InverseBooleanConverter}}" Margin="5,0" />
</StackPanel>
</localView:ImpegniBaseView.ActionButtons>
</localView:ImpegniBaseView>
在 Vs 2010 中,我可以轻松地选择,例如,设计器中的按钮“Salva”。我现在不可以。我想我必须更改设计器中的一个选项,但我不知道是哪个...
更新跟随用作模板的用户控件的相关部分
<UserControl x:Class="Ragioneria.View.ImpegniBaseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Ragioneria"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="700">
<DockPanel DataContext="{Binding ImpegnoSelezionato}">
<DockPanel DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
<Label Content="Anno/Num-Sub" Height="28" HorizontalAlignment="Left" Margin="5" Name="label1" VerticalAlignment="Top" Width="Auto" />
<ContentControl Content="{Binding Path=IdentificazioneImpegnoSection, RelativeSource={RelativeSource AncestorType=UserControl}}" Width="400" Height="28" Margin="5" />
</StackPanel>
<TextBox Height="28" Width="100" Name="textBox9" Text="{Binding Path=DataRegistrazione, StringFormat=d}" DockPanel.Dock="Right" Style="{DynamicResource tb_readonly}" TextAlignment="Right" Margin="5" />
<Label Content="Data" Height="28" Margin="5" Name="label7" Width="50" DockPanel.Dock="Right"/>
</DockPanel>
<ContentControl DockPanel.Dock="Bottom"
DataContext="{Binding DataContext.ActiveWorkspace, RelativeSource={RelativeSource AncestorType=Window}}"
Content="{Binding Path=ActionButtons, RelativeSource={RelativeSource AncestorType=UserControl}}" />
</DockPanel>
谢谢菲利波