Xaml设计师在VS 2012和VS 2010中表现不同

时间:2012-10-31 13:55:15

标签: visual-studio-2010 visual-studio xaml controltemplate

我最近从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>

由于 菲利普

1 个答案:

答案 0 :(得分:0)

您必须将[AlternateContentProperty]添加到ActionButtons

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

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

由于这是来自Visual Studio的不可再发行的dll,因此您无法直接引用它并且必须进行create设计器元数据汇编。

bug 并投票here