powered by simpleCommunicator - 2.0.51     © 2025 Programmizd 02
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Property UserControl Trigger
2 сообщений из 2, страница 1 из 1
Property UserControl Trigger
    #37937180
mr Vap
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Подскажите с 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
Property UserControl Trigger
    #37938624
Фотография Алексей К
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
В UserControl с триггерами туго. Пиши CustomControl.
...
Рейтинг: 0 / 0
2 сообщений из 2, страница 1 из 1
Форумы / WPF, Silverlight [игнор отключен] [закрыт для гостей] / Property UserControl Trigger
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


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