windows-phone-8 相关问题

Windows Phone 8是Windows Phone的一个版本(2012年10月29日至今),它继承了Windows Phone 7.5并包含许多新功能。

更改列表框中数据绑定文本块的前景色

我正在尝试根据绑定值更改列表框中数据绑定 TextBlock 的前景色。 我的代码如下:xaml 我正在尝试根据绑定值更改 TextBlock 中数据绑定 ListBox 的前景色。 我的代码如下:xaml <Grid.Resources> <converters:ColorConverter x:Key="ColorConverter"/> </Grid.Resources> <ListBox> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Name="TitleText"> <Run Foreground="{Binding Type, Converter={StaticResource ColorConverter}}" Text="&#x20b9;" /> </TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListBox> 颜色转换器类: public class ColorConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value != null) { String Value = (String)value; if (Value.Equals("Credit")) return Colors.Green; else return Colors.Red; } return null; } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } 当我运行代码时,没有错误,但颜色不会改变。 Lorem ipsum dolor sat amet,consectetur adipiscing elit,sed do eiusmod tempor incididunt ut laboure et dolore magna aliqua。发酵蛋白 leo vel orci porta non pulvinar neque laoreet。 Commodo elit 坐在不准的位置。 Vulputate eu scelerisque felis imperdiet proin发酵leo vel orci。 Mattis ullamcorper velit sed ullamcorper morbi Tincidunt ornare Massa。 Sapien faucibus et molestie ac feugiat sed lectus. Id aliquet risus feugiat in ante metus: <TextBlock FontSize="12" FontWeight="Bold" Foreground="White"> <TextBlock.Text> <Binding XPath="Title"/> </TextBlock.Text> </TextBlock> ... sodales ut eu sem 整数: using System; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } } } Ut enim ad minim veniam,quis nostrud 实习 ullamco labouris nisi ut aliquip ex ea commodo consequat..

回答 1 投票 0

如何创建Xap文件

我是WP开发新手,现在站在坚不可摧的墙前: 在 Visual Studio Express 2013 中工作 我创建了一个简单的日记应用程序,在模拟器和设备中一切正常。 但当我需要的时候...

回答 2 投票 0

VK Web API(简单)

我想调用方法“photos.get”并从VK社区检索照片。问题是我无法查看 oid,即owner_id(

回答 2 投票 0

Azure 移动服务与 Azure 通知中心 - 哪个用于推送通知?

这个问题可能经常被问到,但我真的很想知道其中的区别。我完全困惑了。 我计划购买并使用/实施 Windows Azure 用于推送通知、Toast

回答 2 投票 0

在 Windows Phone 8 中使用 HttpClient 执行 POST 时出现内部服务器错误

我用这种方式将字符串发布到网络服务器: 私有异步任务 makeRequest(string url, string postData) { HttpClient 客户端 = null; HttpResponseMessage 响应 = null; ...

回答 6 投票 0

强制 MediaElement 在播放后释放流

我正在创建一个录音机控件,具有播放功能。 我使用媒体元素来播放录制的音频,如下所示: 使用 (var storage = System.IO.IsolatedStorage.IsolatedStorage...

回答 4 投票 0

Windows Phone 8.1下可以获取IP接口名称吗?

我正在开发的一个C++跨平台应用程序需要枚举设备上的所有活动IP并区分Wi-Fi IP和热点IP。我的方法是比较 IP 接口...

回答 1 投票 0

从任务回调到主线程

由于我对线程不太了解,所以我有一个问题。 我想在后台做一些事情,在后台方法中我想在某些条件下切换回主线程,否则在 backgr 中工作...

回答 2 投票 0

TextBox 只能大写

我希望文本框仅采用大写。在Windows Phone中它没有CharacterCasing,我能想到的唯一解决方案是: 私有无效textBox_TextChanged(对象发送者,TextChangedEventArgs e) {...

回答 7 投票 0

将曲目添加到播放列表 SoundCloud API

在我的 Windows Phone 应用程序中,我使用以下代码将曲目添加到播放列表(即对播放列表/id 端点的 PUT 请求) 使用 (HttpClient httpClient = new HttpClient()) {

回答 2 投票 0

Windows Phone 8 设备作为感应访问卡

Lumia 920 中的 NFC 硬件可以模拟 125 kHz 感应卡吗? 看起来 NFC 硬件实现的标准是门禁卡使用的标准的超集。但是...

回答 3 投票 0

从另一个线程更新 UI 线程仅适用于某些值

我有一个应用程序可以在另一个线程中进行一些下载。文件大小太大,无法在 UI 线程中下载,因为它会冻结 UI。 初始化线程: 线程 oThread = 新线程(新

回答 1 投票 0

Windows Phone 保留以前的安装

如何保留以前的安装及其引用的DLL文件?我尝试过,但它先卸载,然后将新的 DLL 文件复制到以前的位置。我已更改发行商和产品 ID...

回答 1 投票 0

当json为字符串格式时如何设置json中的参数

如何在json中设置参数这个json是字符串类型,我使用的是c#代码。 这是我的 json; 双纬度 = e.current.Latitude; 双经度 = e.current.Longitude; 字符串 json = "{ \"

回答 4 投票 0

从 ContentControl 绑定前景

我遇到 WindowsPhone 8 和 ControlTemplate 的绑定问题。 这是一个例子: <Setter Property="Template"> ...</desc> <question vote="0"> <p>我遇到 WindowsPhone 8 和 ControlTemplate 的绑定问题。 这是一个例子:</p> <pre><code>&lt;UserControl.Resources&gt; &lt;Style TargetType=&#34;Button&#34;&gt; &lt;Setter Property=&#34;Template&#34;&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType=&#34;Button&#34;&gt; &lt;ContentControl x:Name=&#34;ContentContainer&#34; Foreground=&#34;Red&#34; Content=&#34;{TemplateBinding Content}&#34;/&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Button&gt; &lt;Button.Content&gt; &lt;TextBlock Text=&#34;123&#34;/&gt; &lt;/Button.Content&gt; &lt;Button&gt; </code></pre> <p>我想在我的 Button.Content 中使用我在 ContentContainer 中定义的前景“红色”。但没有任何作用... 目标是更改我的 Style 中 VisualState 中的 ContentContainer 前景。有人可以帮助我吗?</p> </question> <answer tick="false" vote="0"> <p>你应该这样做:</p> <pre><code>&lt;Button Content=&#34;123&#34;/&gt; </code></pre> <p>而不是放置 TextBlock。</p> <p>但是,如果你想保留 TextBlock,你应该这样做:</p> <pre><code>&lt;Style TargetType=&#34;TextBlock&#34;&gt; &lt;Setter Property=&#34;Foreground&#34;&gt; &lt;Setter.Value&gt; red &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> </answer> <answer tick="false" vote="0"> <p>设法通过一种行为来实现这一目标。这是一个相当复杂的解决方案 但这是我发现唯一有效的:</p> <p>首先,一些实用工具:</p> <pre><code>public static class IEnumerableExt { public static T FirstOrDefault&lt;T&gt;(this IEnumerable&lt;T&gt; source) { if (source.Count() &gt; 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&lt;DependencyObject&gt; GetChildren(this DependencyObject @this) { for(int i = 0; i &lt; VisualTreeHelper.GetChildrenCount(@this); i++) { yield return @this.GetChild(i); } } public static IEnumerable&lt;T&gt; FindChildrenOfType&lt;T&gt;(this DependencyObject @this) where T : DependencyObject { foreach(var child in @this.GetChildren()) { if(child is T) { yield return child as T; } } } public static IEnumerable&lt;T&gt; FindDescendantsOfType&lt;T&gt;(this DependencyObject @this) where T : DependencyObject { IEnumerable&lt;T&gt; result = Enumerable.Empty&lt;T&gt;(); foreach(var child in @this.GetChildren()) { if(child is T) { result = result.Concat(child.ToEnumerable().Cast&lt;T&gt;()); } result = result.Concat(child.FindDescendantsOfType&lt;T&gt;()); } return result; } } </code></pre> <p>现在,让我们定义一个执行绑定的行为:</p> <pre><code>public class ContentControlForegroundBindingBehavior : Behavior&lt;Control&gt; { public static DependencyProperty ParentProperty = DependencyProperty.Register(&#34;Parent&#34;, 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) =&gt; { if (Parent == null) return; var control = AssociatedObject as Control; if (control == null) return; var contentControl = Parent.FindDescendantsOfType&lt;ContentControl&gt;().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=&#34;clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity&#34; xmlns:behaviors=&#34; ---------- Your Behaviors Namespace ---------&#34; &lt;Button x:Name=&#34;SomeName&#34; Width=&#34;125&#34; Height=&#34;30&#34; Click=&#34;OnButtonClick&#34; HorizontalAlignment=&#34;Left&#34; VerticalAlignment=&#34;Top&#34; Margin=&#34;50,54,0,0&#34;&gt; &lt;Button.Content&gt; &lt;controls:IconText Icon=&#34;SomeIcon.png&#34; Text=&#34;SomeText&#34;&gt; &lt;i:Interaction.Behaviors&gt; &lt;behaviors:ContentControlForegroundBindingBehavior Parent=&#34;{Binding ElementName=SomeName}&#34;/&gt; &lt;/i:Interaction.Behaviors&gt; &lt;/controls:IconText&gt; &lt;/Button.Content&gt; &lt;/Button&gt; </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>&lt;Style TargetType=&#34;Button&#34;&gt; &lt;Setter Property=&#34;Template&#34;&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType=&#34;Button&#34;&gt; &lt;ContentControl x:Name=&#34;ContentContainer&#34; TextElement.Foreground=&#34;Red&#34; Content=&#34;{TemplateBinding Content}&#34;/&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/UserControl.Resources&gt; &lt;Button&gt; &lt;Button.Content&gt; &lt;TextBlock Text=&#34;123&#34; Foreground=&#34;{TemplateBinding TextElement.Foreground}&#34;/&gt; &lt;/Button.Content&gt; &lt;Button&gt;``` </code></pre> </answer> </body></html>

回答 0 投票 0

Windows Phone 8 支持后台进程(无 UI)? [已关闭]

正如标题所说,现在Windows Phone 8支持后台进程(无UI)?

回答 1 投票 0

如何裁剪大图像以扫描条形码

我正在开发一个WP8应用程序来使用ZXing扫描条形码。如果图像仅包含ITF条码,则可以扫描条码。但是,如果条形码位于大图像内,则该方法不起作用。 所以我想...

回答 2 投票 0

返回图像 url 作为 Web api 2 查询的结果

编辑: 我已经更新了控制器以获取流资源,但有些它仍然不起作用 公共类ResourcesController:控制器 { 公共字符串目录 = @"D:\Desktop\MusicDat...

回答 1 投票 0

在代码中动态设置控件的StaticResource样式

比方说,我有这样的东西(在 MainPage.xaml 中): <Setter Property="FontFamily" Value="S...</desc> <question vote="20"> <p>比方说,我有这样的东西(在 MainPage.xaml 中):</p> <pre><code>&lt;Page.Resources&gt; &lt;Style TargetType=&#34;TextBlock&#34; x:Key=&#34;TextBlockStyle&#34;&gt; &lt;Setter Property=&#34;FontFamily&#34; Value=&#34;Segoe UI Light&#34; /&gt; &lt;Setter Property=&#34;Background&#34; Value=&#34;Navy&#34; /&gt; &lt;/Style&gt; &lt;/Page.Resources&gt; </code></pre> <p>然后,我想将该 StaticResource 样式应用到我动态创建的 TextBlock(文件 MainPage.xaml.cs)。</p> <p>是否有可能这样做而不是这样做:</p> <pre><code>myTextBlock.FontFamily = new FontFamily(&#34;Segoe UI Light&#34;); 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>&lt;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34; ?&gt;&lt;Application xmlns=&#34;http://xamarin.com/schemas/2014/forms&#34; xmlns:x=&#34;http://schemas.microsoft.com/winfx/2009/xaml&#34; x:Class=&#34;SharedUi.App&#34;&gt; &lt;Application.Resources&gt; &lt;ResourceDictionary&gt; &lt;Style x:Key=&#34;BlueButton&#34; TargetType=&#34;Button&#34;&gt; &lt;Setter Property=&#34;TextColor&#34; Value=&#34;White&#34; /&gt; &lt;Setter Property=&#34;FontSize&#34; Value=&#34;20&#34; /&gt; &lt;Setter Property=&#34;BackgroundColor&#34; Value=&#34;Blue&#34;/&gt; &lt;Setter Property=&#34;HeightRequest&#34; Value=&#34;70&#34;/&gt; &lt;Setter Property=&#34;FontAttributes&#34; Value=&#34;Bold&#34;/&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; &lt;/Application.Resources&gt;&lt;/Application&gt; </code></pre> <p>然后在后面的代码中</p> <pre><code>Button newButton1 = new Button { Text = &#34;Hello&#34;, WidthRequest = (double)15.0, Style = (Style)Application.Current.Resources[&#34;BlueButton&#34;] }; </code></pre> </answer> <answer tick="false" vote="13"> <p>你可以这样设置,</p> <pre><code> TextBlock myTextBlock= new TextBlock () { FontFamily = new FontFamily(&#34;Segoe UI Light&#34;); Style = Resources[&#34;TextBlockStyle&#34;] as Style, }; </code></pre> </answer> <answer tick="false" vote="3"> <p>您可以使用这个:</p> <pre><code>Style textBlockStyle; try { textBlockStyle = FindResource(&#34;TextBlockStyle&#34;) 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(&#34;TextBlockStyle&#34;); </code></pre> </answer> <answer tick="false" vote="0"> <pre><code> private void initializedynamicButton() { pnlContent.Children.Clear(); for (int i = 0; i &lt; 25; i++) { Button btn = new Button(); btn.Style = (Style)this.FindResource(&#34;GelButton&#34;); btn.Content = new { Text = &#34;ButtonName_&#34;+i.ToString(), ImagePath = &#34;&#34;, 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>

回答 0 投票 0

使用后退按钮时阻止用户访问应用程序

我正在制作一个简单的密码管理应用程序,它要求用户记住一个“主密码”以访问他/她存储在应用程序中的所有其他密码。 然而我的问题是...

回答 4 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.