Windows Phone 8是Windows Phone的一个版本(2012年10月29日至今),它继承了Windows Phone 7.5并包含许多新功能。
我是WP开发新手,现在站在坚不可摧的墙前: 在 Visual Studio Express 2013 中工作 我创建了一个简单的日记应用程序,在模拟器和设备中一切正常。 但当我需要的时候...
我想调用方法“photos.get”并从VK社区检索照片。问题是我无法查看 oid,即owner_id(
Azure 移动服务与 Azure 通知中心 - 哪个用于推送通知?
这个问题可能经常被问到,但我真的很想知道其中的区别。我完全困惑了。 我计划购买并使用/实施 Windows Azure 用于推送通知、Toast
在 Windows Phone 8 中使用 HttpClient 执行 POST 时出现内部服务器错误
我用这种方式将字符串发布到网络服务器: 私有异步任务 makeRequest(string url, string postData) { HttpClient 客户端 = null; HttpResponseMessage 响应 = null; ...
我正在创建一个录音机控件,具有播放功能。 我使用媒体元素来播放录制的音频,如下所示: 使用 (var storage = System.IO.IsolatedStorage.IsolatedStorage...
Windows Phone 8.1下可以获取IP接口名称吗?
我正在开发的一个C++跨平台应用程序需要枚举设备上的所有活动IP并区分Wi-Fi IP和热点IP。我的方法是比较 IP 接口...
由于我对线程不太了解,所以我有一个问题。 我想在后台做一些事情,在后台方法中我想在某些条件下切换回主线程,否则在 backgr 中工作...
我希望文本框仅采用大写。在Windows Phone中它没有CharacterCasing,我能想到的唯一解决方案是: 私有无效textBox_TextChanged(对象发送者,TextChangedEventArgs e) {...
在我的 Windows Phone 应用程序中,我使用以下代码将曲目添加到播放列表(即对播放列表/id 端点的 PUT 请求) 使用 (HttpClient httpClient = new HttpClient()) {
Lumia 920 中的 NFC 硬件可以模拟 125 kHz 感应卡吗? 看起来 NFC 硬件实现的标准是门禁卡使用的标准的超集。但是...
我有一个应用程序可以在另一个线程中进行一些下载。文件大小太大,无法在 UI 线程中下载,因为它会冻结 UI。 初始化线程: 线程 oThread = 新线程(新
如何保留以前的安装及其引用的DLL文件?我尝试过,但它先卸载,然后将新的 DLL 文件复制到以前的位置。我已更改发行商和产品 ID...
如何在json中设置参数这个json是字符串类型,我使用的是c#代码。 这是我的 json; 双纬度 = e.current.Latitude; 双经度 = e.current.Longitude; 字符串 json = "{ \"
我遇到 WindowsPhone 8 和 ControlTemplate 的绑定问题。 这是一个例子: <Setter Property="Template"> ...</desc> <question vote="0"> <p>我遇到 WindowsPhone 8 和 ControlTemplate 的绑定问题。 这是一个例子:</p> <pre><code><UserControl.Resources> <Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <ContentControl x:Name="ContentContainer" Foreground="Red" Content="{TemplateBinding Content}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <Button> <Button.Content> <TextBlock Text="123"/> </Button.Content> <Button> </code></pre> <p>我想在我的 Button.Content 中使用我在 ContentContainer 中定义的前景“红色”。但没有任何作用... 目标是更改我的 Style 中 VisualState 中的 ContentContainer 前景。有人可以帮助我吗?</p> </question> <answer tick="false" vote="0"> <p>你应该这样做:</p> <pre><code><Button Content="123"/> </code></pre> <p>而不是放置 TextBlock。</p> <p>但是,如果你想保留 TextBlock,你应该这样做:</p> <pre><code><Style TargetType="TextBlock"> <Setter Property="Foreground"> <Setter.Value> red </Setter.Value> </Setter> </Style> </code></pre> </answer> <answer tick="false" vote="0"> <p>设法通过一种行为来实现这一目标。这是一个相当复杂的解决方案 但这是我发现唯一有效的:</p> <p>首先,一些实用工具:</p> <pre><code>public static class IEnumerableExt { public static T FirstOrDefault<T>(this IEnumerable<T> source) { if (source.Count() > 0) return source.ElementAt(0); return default(T); } } </code></pre> <p>并且...</p> <pre><code>public static class DependencyObjectExt { public static DependencyObject GetChild(this DependencyObject @this, int childIndex) { return VisualTreeHelper.GetChild(@this, childIndex); } public static IEnumerable<DependencyObject> GetChildren(this DependencyObject @this) { for(int i = 0; i < VisualTreeHelper.GetChildrenCount(@this); i++) { yield return @this.GetChild(i); } } public static IEnumerable<T> FindChildrenOfType<T>(this DependencyObject @this) where T : DependencyObject { foreach(var child in @this.GetChildren()) { if(child is T) { yield return child as T; } } } public static IEnumerable<T> FindDescendantsOfType<T>(this DependencyObject @this) where T : DependencyObject { IEnumerable<T> result = Enumerable.Empty<T>(); foreach(var child in @this.GetChildren()) { if(child is T) { result = result.Concat(child.ToEnumerable().Cast<T>()); } result = result.Concat(child.FindDescendantsOfType<T>()); } return result; } } </code></pre> <p>现在,让我们定义一个执行绑定的行为:</p> <pre><code>public class ContentControlForegroundBindingBehavior : Behavior<Control> { public static DependencyProperty ParentProperty = DependencyProperty.Register("Parent", typeof(Control), typeof(ContentControlForegroundBindingBehavior), new PropertyMetadata(null)); public Control Parent { get { return (Control)this.GetValue(ParentProperty); } set { this.SetValue(ParentProperty, value); } } protected override void OnAttached() { base.OnAttached(); AssociatedObject.Loaded += (sender, e) => { if (Parent == null) return; var control = AssociatedObject as Control; if (control == null) return; var contentControl = Parent.FindDescendantsOfType<ContentControl>().FirstOrDefault(); if (contentControl == null) return; control.SetBinding(Control.ForegroundProperty, new Binding() { NotifyOnSourceUpdated = true, Mode = BindingMode.OneWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged, BindsDirectlyToSource = true, Path = new PropertyPath(Control.ForegroundProperty), Source = contentControl }); }; } } </code></pre> <p>此行为的作用是将控件的前景绑定到指定父级模板中找到的 ContentControl 的前景。 这就是你如何使用它(在 xaml 中):</p> <pre><code>xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:behaviors=" ---------- Your Behaviors Namespace ---------" <Button x:Name="SomeName" Width="125" Height="30" Click="OnButtonClick" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="50,54,0,0"> <Button.Content> <controls:IconText Icon="SomeIcon.png" Text="SomeText"> <i:Interaction.Behaviors> <behaviors:ContentControlForegroundBindingBehavior Parent="{Binding ElementName=SomeName}"/> </i:Interaction.Behaviors> </controls:IconText> </Button.Content> </Button> </code></pre> </answer> <answer tick="false" vote="0"> <p>现在是 2023 年,Windows Phone 已不复存在。我来到这里寻找 WPF .NET 的解决方案,但当时没有找到解决方案。</p> <p>现在我已经制定了一个解决方案(至少对于 WPF .NET),我将其发布在这里,以防其他人像我一样来到这里寻找灵感。</p> <p>解决方案是使用<pre><code>TextElement</code></pre>:</p> <ul> <li>将 <pre><code>TextElement.Foreground</code></pre> 设置在 <pre><code>ContentControl</code></pre></li> 上 <li>在内容的 <pre><code>TemplateBinding</code></pre> 上使用 <pre><code>Foreground</code></pre>。</li> </ul> <p>现在前景色已从 ContentControl 绑定到 ContentControl 的内容。</p> <p>以OP的代码为例:</p> <pre><code><Style TargetType="Button"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Button"> <ContentControl x:Name="ContentContainer" TextElement.Foreground="Red" Content="{TemplateBinding Content}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources> <Button> <Button.Content> <TextBlock Text="123" Foreground="{TemplateBinding TextElement.Foreground}"/> </Button.Content> <Button>``` </code></pre> </answer> </body></html>
我正在开发一个WP8应用程序来使用ZXing扫描条形码。如果图像仅包含ITF条码,则可以扫描条码。但是,如果条形码位于大图像内,则该方法不起作用。 所以我想...
编辑: 我已经更新了控制器以获取流资源,但有些它仍然不起作用 公共类ResourcesController:控制器 { 公共字符串目录 = @"D:\Desktop\MusicDat...
比方说,我有这样的东西(在 MainPage.xaml 中): <Setter Property="FontFamily" Value="S...</desc> <question vote="20"> <p>比方说,我有这样的东西(在 MainPage.xaml 中):</p> <pre><code><Page.Resources> <Style TargetType="TextBlock" x:Key="TextBlockStyle"> <Setter Property="FontFamily" Value="Segoe UI Light" /> <Setter Property="Background" Value="Navy" /> </Style> </Page.Resources> </code></pre> <p>然后,我想将该 StaticResource 样式应用到我动态创建的 TextBlock(文件 MainPage.xaml.cs)。</p> <p>是否有可能这样做而不是这样做:</p> <pre><code>myTextBlock.FontFamily = new FontFamily("Segoe UI Light"); myTextBlock.Background = new SolidColorBrush(Color.FromArgb(255,0,0,128)); </code></pre> </question> <answer tick="true" vote="26"> <p>距离提出这个问题已经过去四年多了,但我想发布一个答案只是为了分享我的发现。 </p> <p>例如,如果<pre><code>Style</code></pre>(Xamarin跨平台应用程序开发)中的应用程序资源中有描述的<pre><code>BlueButton</code></pre><pre><code>App.xaml</code></pre>,则可以按如下方式使用</p> <pre><code><?xml version="1.0" encoding="utf-8" ?><Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="SharedUi.App"> <Application.Resources> <ResourceDictionary> <Style x:Key="BlueButton" TargetType="Button"> <Setter Property="TextColor" Value="White" /> <Setter Property="FontSize" Value="20" /> <Setter Property="BackgroundColor" Value="Blue"/> <Setter Property="HeightRequest" Value="70"/> <Setter Property="FontAttributes" Value="Bold"/> </Style> </ResourceDictionary> </Application.Resources></Application> </code></pre> <p>然后在后面的代码中</p> <pre><code>Button newButton1 = new Button { Text = "Hello", WidthRequest = (double)15.0, Style = (Style)Application.Current.Resources["BlueButton"] }; </code></pre> </answer> <answer tick="false" vote="13"> <p>你可以这样设置,</p> <pre><code> TextBlock myTextBlock= new TextBlock () { FontFamily = new FontFamily("Segoe UI Light"); Style = Resources["TextBlockStyle"] as Style, }; </code></pre> </answer> <answer tick="false" vote="3"> <p>您可以使用这个:</p> <pre><code>Style textBlockStyle; try { textBlockStyle = FindResource("TextBlockStyle") as Style; } catch(Exception ex) { // exception handling } if(textBlockStyle != null) { myTextBlock.Style = textBlockStyle; } </code></pre> <p>或<pre><code>TryFindResource</code></pre>方法:</p> <pre><code>myTextBlock.Style = (Style)TryFindResource("TextBlockStyle"); </code></pre> </answer> <answer tick="false" vote="0"> <pre><code> private void initializedynamicButton() { pnlContent.Children.Clear(); for (int i = 0; i < 25; i++) { Button btn = new Button(); btn.Style = (Style)this.FindResource("GelButton"); btn.Content = new { Text = "ButtonName_"+i.ToString(), ImagePath = "", Margin = new Thickness(0, 0, 0, 10) }; btn.Tag = new { GroupID = i }; btn.Click += new RoutedEventHandler(btn_Click); pnlContent.Children.Add(btn); } } </code></pre> </answer> </body></html>
我正在制作一个简单的密码管理应用程序,它要求用户记住一个“主密码”以访问他/她存储在应用程序中的所有其他密码。 然而我的问题是...
Windows Phone 8 life 磁贴使用标题向用户显示一些信息
我想知道生活板块的字体颜色是否在所有情况下都必须是白色。 基本上,我喜欢在特定时间使用 TileUpdateManager 和 TileNotification 更新我的磁贴标题,以显示...