【问题标题】:Custom Hub Control for WP8.1WP8.1 的自定义集线器控制
【发布时间】:2015-10-22 13:20:06
【问题描述】:

我在理解Hub Control 的构建方式方面存在一些问题。 我想了解的主要思想是如何构建一个自定义控件,该控件允许执行一些手势并且不会阻塞内部控件。

使用Hub 控件,我可以按下Button 并查看其回调(颜色和大小更改),然后将指针向左滑动Hub 控件。

很抱歉这个愚蠢的问题,但我没有足够的经验自己找到任何答案。提前感谢您的任何建议。

【问题讨论】:

  • @Will,感谢重播。你应该推荐合适的工具来做这个吗?
  • 您可以使用您最喜欢的搜索引擎来查找.net 反汇编程序。有很多,尝试一些,找出最适合你的。
  • @Will,我用过JustDecompile,但只有外部调用而已。类似here 的情况。你可以给我建议另一个工具吗?
  • 您没有查看控件的模板。这就是乐趣所在。您的工具将成为您的向导。
  • @Will,这是我做的第一件事。主要技巧隐藏在代码隐藏中。 HubHubSection 的模板非常简单。

标签: c# windows-phone-8 windows-runtime uigesturerecognizer


【解决方案1】:

主要问题与使用GestureRecognizer 有关。 我已经解决了拒绝使用 GestureRecognizer 并开始在主容器上使用操作事件的问题。

简化的模板代码:

<Style TargetType="my:CustomHub">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="my:CustomHub">
                <Grid x:Name="RootGrid">
                    <ContentPresenter x:Name="MainPresenter" 
                                      Content="{TemplateBinding Content}" />
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

控件的代码隐藏:

public sealed class CustomHub
{
    public FrameworkElement Container { get; set; }

    public MainView()
    {
        this.InitializeComponent();
    }

    private void InitGestureInteraction()
    {
        this.Container = (FrameworkElement)GetTemplateChild("RootGrid");
        this.Container.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateRailsX;

        this.Container.ManipulationStarted += (s, e) =>
        {
        };

        this.Container.ManipulationDelta += (s, e) =>
        {
            var x = e.Cumulative.Translation.X;
            // implementation of moving
        };

        this.Container.ManipulationCompleted += (s, e) =>
        {
            var x = e.Cumulative.Translation.X;
            // implementation of moving
        };
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    相关资源
    最近更新 更多