内容控件中定义的面板的绝对定位

时间:2016-11-23 06:20:14

标签: c# xaml uwp winrt-xaml uwp-xaml

我试图通过继承Control类(带有自定义操作的按钮)在Windows UWP中编写自定义控件。单击此按钮时,我想在页面底部显示一个面板,而不管页面中控件的使用位置(弹出窗口类型,但我需要自由定义面板在屏幕上的位置)。

任何人都可以帮助我在XAML中完成这项工作。下面是我用于自定义控件的模板。

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UI.Controls"
    xmlns:converters="using:UI.ValueConverters">
    <Style TargetType="local:Plugin">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:Plugin">
                    <Grid>
                        <Grid.Resources>
                            <converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
                            <x:Double x:Key="EllipseDimension">30</x:Double>
                        </Grid.Resources>
                        <Button Name="PluginButton"
                                Width="{TemplateBinding PluginWidth}"
                                Height="{TemplateBinding PluginHeight}"
                                Command="{Binding PluginTrigger}"
                                Padding="0"
                                VerticalAlignment="Top"
                                AutomationProperties.Name="Main button"
                                Background="Transparent"
                                BorderThickness="0"
                                TabIndex="0">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="48" />
                                </Grid.ColumnDefinitions>
                                <SymbolIcon Symbol="{TemplateBinding Symbol}"
                                            Visibility="{Binding Image, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=true}"
                                            Foreground="Black"
                                            VerticalAlignment="Center"
                                            HorizontalAlignment="Center"
                                            ToolTipService.ToolTip="{TemplateBinding Label}" />

                                <Ellipse Visibility="{Binding Image, Converter={StaticResource NullToVisibilityConverter}}"
                                         Width="{StaticResource EllipseDimension}" 
                                         Height="{StaticResource EllipseDimension}">
                                    <Ellipse.Fill>
                                        <ImageBrush ImageSource="{Binding Image}" />
                                    </Ellipse.Fill>
                                </Ellipse>
                            </Grid>
                        </Button>
                        <StackPanel Name="popuptoshow"></StackPanel>
                    </Grid>

                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>

0 个答案:

没有答案