событие как свойство зависимости wpf - PullRequest
0 голосов
/ 21 октября 2019

с простыми элементами управления, я могу добавить свойство зависимости следующим образом:

public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("CommandName"), typeof(ICommand), typeof(controlType));

public ICommand Command
{
   get { return (ICommand)GetValue(CommandProperty);}
   set {this.SetValue(CommandProperty,value);}
}

стиль:

<Style BasedOn="{StaticResource {x:Type ContentControl}}" TargetType="{x:Type local:ControlType}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type local:ControlType}">
                <Grid x:Name="titleGrid" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                        <local:DSMoveThumb
                            Title="thumb"/>
                        <button Command={TemplateBinding Command}/>
                        <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Hidden">
                            <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" />
                        </ScrollViewer>
                    </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

, чтобы я мог привязать его следующим образом:

<local:control CommandName={Binding ViewModelCommand} />

Я хотел бы сделать то же самое, но для события двойного щелчка на большой части стиля, но мне трудно разобраться. Любой вклад будет оценен.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...