Visual studio 2010 Xaml设计器在VS 2012和VS 2010中的行为有所不同

Visual studio 2010 Xaml设计器在VS 2012和VS 2010中的行为有所不同,visual-studio-2010,visual-studio,xaml,controltemplate,Visual Studio 2010,Visual Studio,Xaml,Controltemplate,我最近从VS2010转到Visual Studio 2012。 我有一些用户控件,它们是其他用户控件的模板。 第一个控件有一些ContentControl,其内容在第二个控件中定义 遵循基于模板控件(ImpegniBaseView)的用户控件的定义 在VS2010中,我可以很容易地选择,例如,设计器中的“Salva”按钮。现在我不能。我想我必须在设计器中更改一个选项,但我不知道是哪一个 更新 遵循用作模板的用户控件的相关部分 <UserControl x:Class="Ragioner

我最近从VS2010转到Visual Studio 2012。 我有一些用户控件,它们是其他用户控件的模板。 第一个控件有一些ContentControl,其内容在第二个控件中定义

遵循基于模板控件(ImpegniBaseView)的用户控件的定义


在VS2010中,我可以很容易地选择,例如,设计器中的“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>

谢谢
Filippo

您必须将
[AlternateContentProperty]
添加到
操作按钮中

不幸的是,与Silverlight不同,您在标准库中找不到该属性

相反,您需要使用Microsoft.Windows.Design.Interaction.dll中的Microsoft.Windows.Design.PropertyEdit.AlternateContentProperty

由于这是Visual Studio中不可再发行的dll,所以您不能直接引用它,必须使用设计器元数据程序集

看到这个了吗
然后投票。

你为什么不直接使用Blend?VS 2012更简单,你说的“可以轻松选择”是什么意思?为什么现在不能选择?我真的不明白你在描述什么,虽然我假设你想看看是否有办法恢复丢失的行为,但你没有问任何问题。在VS2010中,我可以用鼠标点击按钮,它被选中。在Vs2012中,我只能选择用户控件,似乎无法在设计器中访问其中的按钮。相反,如果我选择按钮的xaml,它也会在设计器中被选中。我想恢复Vs 2010的行为。怎样?
<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>