小编rob*_*rtk的帖子

Windows Phone 8.1 Silverlight中的Toast Notification参数

好的,所以我在8.1 SL项目中使用新的ToastNotificationManager而不是旧的ShellToast.ShellToast在toast消息上有NavigationUri,这非常容易.

在新的祝酒词中,你必须根据这篇文章自己指定启动参数.但是看起来8.1 SL没有事件OnLaunched(LaunchActivatedEventArgs args)你应该在App.xaml.cs中监听参数:

第2步:处理应用程序的"OnLaunched"事件

当用户点击您的祝酒词或通过触摸选择它时,相关的应用程序将启动,同时启动其OnLaunched事件.

注意如果您在Toast中未包含启动属性字符串,并且在选择Toast时您的应用程序已在运行,则不会触发OnLaunched事件.

此示例显示了OnLaunched事件的覆盖语法,您将在其中检索并处理通过Toast通知提供的启动字符串.

protected override void OnLaunched(LaunchActivatedEventArgs args)
{
    string launchString = args.Arguments

    ....
}
Run Code Online (Sandbox Code Playgroud)

我的代码:

// Using the ToastText02 toast template.
ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;

// Retrieve the content part of the toast so we can change the text.
XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

//Find the text component of the content
XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

// Set the text on the toast. 
// The first line of text in the …
Run Code Online (Sandbox Code Playgroud)

c# windows-phone-8 windows-phone-8-sdk windows-phone-8.1

11
推荐指数
1
解决办法
7851
查看次数

覆盖主题画笔Windows 10 UWP

我试图在Windows 10中覆盖一些样式颜色,但我无法让它工作.

我的app.xaml看起来像这样:

        <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="Resources.xaml"/>
        </ResourceDictionary.MergedDictionaries>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Default" Source="Theme.xaml"/>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)

我的Theme.xaml看起来像这样

<ResourceDictionary
x:Key="Default"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<SolidColorBrush x:Key="ListBoxBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ListBoxFocusBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ListBoxItemPressedBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ListBoxItemSelectedForegroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ListBoxItemSelectedBackgroundThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="FocusVisualBlackStrokeThemeBrush" Color="Transparent" />
<SolidColorBrush x:Key="ScrollBarButtonForegroundThemeBrush" Color="Red" />
<SolidColorBrush x:Key="ScrollBarPanningBackgroundThemeBrush" Color="Red" />
<SolidColorBrush x:Key="ButtonPressedBackgroundThemeBrush" Color="White"/>

<SolidColorBrush x:Key="SearchBoxHitHighlightSelectedForegroundThemeBrush" Color="Red"/>
<SolidColorBrush x:Key="SearchBoxHitHighlightForegroundThemeBrush" Color="Pink"/>
Run Code Online (Sandbox Code Playgroud)

但它不起作用,它不会覆盖任何地方的样式.

xaml windows-phone win-universal-app windows-10

11
推荐指数
1
解决办法
6335
查看次数

适合当前应用中的当前元素宽度屏幕

我正在尝试为Windows 10开发一个应用程序.但是对于全新的屏幕显示,我似乎无法弄清楚如何使元素适合设备屏幕的当前大小.

例如,如果您调整窗口大小,我希望TextBlock适合窗口的宽度.我已经尝试过ViewBox,VariableSIzedWrapGrid等等,但似乎没有什么能解决我的问题.有谁知道? 在此输入图像描述

更新:这是我试图适应下面窗口大小的搜索框.网格填充整个窗口,如果我在其上放置背景颜色,也会填充RelativePanel.但SearchBox拒绝拉伸...我不希望搜索框的大小缩放,只是它的宽度适合窗口/设备宽度.

        <!-- SEARCH GRID -->
    <Grid Canvas.ZIndex="5" x:Name="GridSearchPackage" HorizontalAlignment="Stretch" Visibility="Visible" Opacity="0.85" Background="White">
        <RelativePanel HorizontalAlignment="Stretch" Margin="5,5,0,0" >
            <Button x:Name="ButtonBackSearchGrid" Height="36" Width="36" FontSize="10" Margin="0,7,5,0"
                  Style="{StaticResource BackButtonStyle}"
                  Click="ButtonBackSearchGrid_Click"
                  AutomationProperties.Name="Back"
                  AutomationProperties.AutomationId="BackButton"
                  AutomationProperties.ItemType="Navigation Button" BorderBrush="Black" BorderThickness="3">
                <FontIcon x:Name="backButtonIcon" FontWeight="Bold" FontSize="20" Foreground="{StaticResource AppDarkBlueColor}" Glyph="&#xE72B;" />
            </Button>
            <TextBlock x:Name="TextBlockPopupSearchTitle" RelativePanel.RightOf="ButtonBackSearchGrid" Foreground="{StaticResource AppDefaultBlueColor}" Text="Search XZY" FontSize="34"/>
            <SearchBox FontSize="20" RelativePanel.Below="TextBlockPopupSearchTitle" HorizontalAlignment="Stretch" PlaceholderText="search" Margin="0,10,0,0" QuerySubmitted="SearchBox_QuerySubmitted" QueryText="{Binding SearchText, Mode=TwoWay}"/>
        </RelativePanel>
    </Grid>
Run Code Online (Sandbox Code Playgroud)

xaml windows-phone winrt-xaml win-universal-app windows-10

0
推荐指数
1
解决办法
5401
查看次数