样式importet XAML组件

时间:2014-02-21 10:10:26

标签: c# .net wpf xaml

我有一个带有stackpanel定义资源的XAML文件。我想做的是在<ResourceProfileViews:DescriptionView/>中设置TextBox样式,而不影响此视图中的其他TextBlox。

我的“主要”观点。

<UserControl x:Class="Comsol.STEA.ProjectViewModule.View.ResourceProfileView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Resources="clr-namespace:Comsol.STEA.Core.Resources;assembly=Core" 
    xmlns:Converters1="clr-namespace:Comsol.STEA.Core.Utilities.Converters;assembly=Core" 
    xmlns:Commands="clr-namespace:Comsol.STEA.ProjectViewModule.Commands" 
    xmlns:ResourceProfileViews="clr-namespace:Comsol.STEA.ProjectViewModule.View.ResourceProfileViews"
    xmlns:Behaviors="clr-namespace:WpfLib.Behaviors;assembly=WpfLib"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/Resources.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Converters1:BoolToCollapsedVisibilityConverter x:Key="btcvc"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <StackPanel Background="{DynamicResource SteaBackgroundBrush}"
                FocusManager.FocusedElement="{Binding ElementName=NameBox}">
        <StackPanel.Resources>
            <Style TargetType="{x:Type TextBox}">
                <Setter Property="Width" Value="360"/>
                <Setter Property="MinLines" Value="3"/>
            </Style>
        </StackPanel.Resources>
        <GroupBox Header="{x:Static Resources:Strings.ProfileSettings}">
            <StackPanel>
                <AdornerDecorator Visibility="{Binding Path=AnyAvailableCategories, Converter={StaticResource btcvc}}">
                    <StackPanel>
                        <ResourceProfileViews:DescriptionView/>         
                    </StackPanel>
                </AdornerDecorator>
            </StackPanel>
        </GroupBox>
    </StackPanel>
</UserControl>

DescriptionView

<StackPanel Orientation="Horizontal">
    <Label Content="{x:Static Resources:Strings.Description}"/>
    <TextBox Text="{Binding Path=Description, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True}"/>            
</StackPanel>

0 个答案:

没有答案