Гость
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Property UserControl Trigger / 2 сообщений из 2, страница 1 из 1
30.08.2012, 14:43
    #37937180
mr Vap
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Property UserControl Trigger
Подскажите с Trigger'ом нужно чтобы, при изменение isTest в дизайнере, чего нибудь происходило

Код: vbnet
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
Public Class UCT
    Public Shared ReadOnly isTestProperty As DependencyProperty = DependencyProperty.Register("isTest", GetType(Boolean), GetType(UCT))
    <Category("Common")>
    Public Property isTest As Boolean
        Get
            Return CType(Me.GetValue(isTestProperty), Boolean)
        End Get
        Set(ByVal value As Boolean)
            Me.SetValue(isTestProperty, value)
        End Set
    End Property
End Class



Код: vbnet
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
<UserControl x:Class="UCT"
             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:my="clr-namespace:WpfApplication1"
             xmlns:UserControls="clr-namespace:WpfApplication1" mc:Ignorable="d" 
             xmlns:src="clr-namespace:WpfApplication1"
             x:Name="MyEventControl"
             d:DesignHeight="22" d:DesignWidth="300">
    <UserControl.Template>
        <ControlTemplate TargetType="{x:Type UserControl}" >
            
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <CheckBox x:Name="UC" VerticalAlignment="Center" 
                          IsChecked="{Binding Path=isTest, RelativeSource={RelativeSource FindAncestor, AncestorType=src:UCT, AncestorLevel=1}}"
                          Content="{Binding Path=isTest, RelativeSource={RelativeSource FindAncestor, AncestorType=src:UCT, AncestorLevel=1}}">
                </CheckBox>
                <Label x:Name="UT" Background="#FFE2E2FF" 
                       BorderBrush="#FFEA1212" 
                       Padding="0" 
                       VerticalContentAlignment="Center" Grid.Column="1">
                </Label>
            </Grid>
            <ControlTemplate.Resources>
                 
            </ControlTemplate.Resources>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter TargetName="UT" Property="Content" Value="IsMouseOver" />
                    <Setter TargetName="UT" Property="Background" Value="White" />
                </Trigger>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=src:UCT, AncestorLevel=1}, Path=isTest, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Value="true">
                    <Setter TargetName="UT" Property="Content" Value="isError" />
                    <Setter TargetName="UT" Property="Background" Value="Red" />
                    <Setter TargetName="UC" Property="Background" Value="Red" />
                </DataTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </UserControl.Template>
</UserControl>
...
Рейтинг: 0 / 0
31.08.2012, 12:50
    #37938624
Алексей К
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Property UserControl Trigger
В UserControl с триггерами туго. Пиши CustomControl.
...
Рейтинг: 0 / 0
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Property UserControl Trigger / 2 сообщений из 2, страница 1 из 1
Целевая тема:
Создать новую тему:
Автор:
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]