标签: silverlight

如何获取CollectionViewSource的第一个元素?

我记得看过一些代码xaml,可以从集合中获取第一个元素(如索引x [0]).

这是我的Resources的CollectionViewSource.

<CollectionViewSource
            x:Name="groupedItemsViewSource2"
            Source="{Binding Posters}"
            ItemsPath="Posters" />
Run Code Online (Sandbox Code Playgroud)

如果我在列表框中显示它,它加载它!

<ListBox ItemsSource="{Binding Source={StaticResource groupedItemsViewSource2}}" />
Run Code Online (Sandbox Code Playgroud)

但是现在,我只想通过xaml获得第一个元素.有可能这样做吗?

c# silverlight wpf xaml microsoft-metro

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

在WP7中手动退出文本框的键入模式

我的Windows Phone 7应用程序中有一个场景.我有panarama控制,它有4个项目.让我们说第一项我有文本框,我的重点是它意味着我的光标在它,我在这个文本框上打字.但是当我的焦点仍然在文本框中并且我更改全景项目时键入平均值.我的文本框焦点仍然存在,仍处于打字模式.如何在panaroma选择更改时从输入模式退出文本框.

c# silverlight xaml windows-phone-7

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

使用C#动态更改元素的样式

我有一个4x LineSeries的图表.我定义了两种不同的样式来表示线条,我希望能够动态地更改应用于特定LineSeries的样式(例如,基于用户点击按钮等).

我似乎无法弄清楚如何从c#更新样式.任何帮助赞赏!

我试过了:

lineChartMood.PolylineStyle = this.Resources.PolylineStyle2 as Style;
Run Code Online (Sandbox Code Playgroud)

但是这会返回Null异常.

这是页面的XAML,包括样式定义:

    <phone:PhoneApplicationPage 
    x:Class="Bhutaan.ChartingTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:local="clr-namespace:Bhutaan"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <Style x:Key="PolylineStyle" TargetType="Polyline">
            <Setter Property="StrokeThickness" Value="5"/>
        </Style>
        <Style x:Key="PolylineStyle2" TargetType="Polyline">
            <Setter Property="StrokeThickness" Value="1"/>
        </Style>
    </phone:PhoneApplicationPage.Resources>


    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel …
Run Code Online (Sandbox Code Playgroud)

c# silverlight windows-phone-7

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

如何在鼠标悬停时更改边框粗细

我正在研究控件的风格.我想在鼠标悬停完成后更改控件的borderthickness.我想在样式本身中编写它,而不是在代码隐藏中编写它

所以,我尝试了以下方式.

<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="Border" Storyboard.TargetProperty="BorderThickness">
<SplineDoubleKeyFrame  KeyTime="0" Value="2" />                                   
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
Run Code Online (Sandbox Code Playgroud)

但这是一个错误.

我该如何实现此功能.

.net silverlight styles blend

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

渲染Silverlight网站时WebView崩溃

我需要从嵌入在MonoMac应用程序中的浏览器访问silverlight 5应用程序.对于浏览器我正在使用MonoMac.WebKit.WebView当试图访问任何silverlight应用程序时

webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl("http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/")));

我收到以下错误http://pastebin.com/s8PDfDyq.我尝试使用XCode中的本机WebView并正确加载,所以我相信是影响它的单声道桥.

除了WebView之外,还有其他方法可以在Mono OSX应用程序中嵌入浏览器吗?

谢谢,克劳迪奥

macos silverlight mono

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

无法找到安装的silverlight开发人员运行时版本

在以下环境中:

-VS2012

-Windows 7 64bit

-Microsoft Silverlight 5 SDK

我在VS2012中创建了一些lightswitch应用程序,但在尝试创建新的或打开现有的lightswitch项目时遇到错误.我收到一个弹出窗口,上面写着"无法找到安装了Silverlight开发人员运行时的版本".

弹出窗口上有一个链接开始下载,但下载后,我仍然收到相同的错误.

silverlight visual-studio-lightswitch silverlight-5.0 visual-studio-2012

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

从代码隐藏动态访问故事板?

我正在开发Windows Phone应用程序,但我相信这也适用Silverlight.我想创建一个Storyboard(现在我创造它在我的测试代码隐藏页的全局变量),其改变RectangleFill由透明属性设置为红色,然后回透明.我将Storyboard在多个矩形中重新使用它,所以我希望能够Begin()从代码隐藏中访问它.我找不到这样的例子,所以我用我认为可行的方法给了它一个镜头.

初始设置:

sb = new Storyboard();

turnOn= new ColorAnimation();
turnOn.From = Colors.Transparent;
turnOn.To = Colors.Red;
turnOn.Duration = new TimeSpan(0, 0, 0, 0, 500); //half second

turnOff= new ColorAnimation();
turnOff.From = Colors.Red;
turnOff.To = Colors.Transparent;
turnOff.Duration = new TimeSpan(0, 0, 0, 0, 500); //half second

Storyboard.SetTargetProperty(turnOn, new PropertyPath("(Rectangle.Fill)"));
Storyboard.SetTargetProperty(turnOff, new PropertyPath("(Rectangle.Fill)"));

sb.Children.Add(turnOn);
sb.Children.Add(turnOff);

canvas.Resources.Add("sb", sb); // this is the canvas where the rectangles will be
Run Code Online (Sandbox Code Playgroud)

然后,在任何时候,如果我有一个Rectangle实例,它将在 …

c# silverlight storyboard windows-phone

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

构建后消失的UserControl

问题:我有一个新制作的UserControl,在父网格中带有几个telerik控件,可以在整个解决方案中使用它。听起来很简单吧?我创建了UserControl,我们将其称为My.Project.Controls.Tool类,然后尝试使用名称空间调用另一个View,xmlns:Controls="clr-namespace:My.Project.Controls;assembly=My.Project.GlobalUserControlDump"然后通过方便的dandy intellisense中轻松选择的名称在视图中进行设置。

正如预期的那样,我的UserControl出现在设计器的单独视图中就好了。因此,我采取了下一步的常规步骤,并进行了构建。...构建完成后(它运行正常,没有报告预期的错误),小虫子消失了!xaml当然仍然在View上,但是它从设计器中消失了,并且没有出现在内置解决方案上吗?

困惑,我回头,对UserControl进行快速更改,它又出现在设计器中。好的,我认为这一定是偶然的,所以我再次构建它。...然后它又从设计师和构建的解决方案中消失了?

现在,我可以继续可靠地重现此方案。对UserControl进行一些更改,它会重新出现在设计器中.....然后进行构建,然后它又消失了!

有人能请您对此杂乱无章的事物有所启发吗?与Caliburn Micro一起在SL中运行(无论是在浏览器中还是在浏览器中,但都内置在浏览器中)。当然,对这个谜的任何见解都会受到赞赏,希望另一双眼睛能抓住我的愚蠢。干杯!

为了澄清起见,这就是用户控件中与上一个问题直接相关的内容

<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    mc:Ignorable="d"
    x:Class="My.Project.Controls.DatePicker">

    <Grid Width="90">
           <telerik:RadDateTimePicker 
                                      InputMode="DatePicker" 
                                      SelectedDate="{Binding SelectedDate, Mode=TwoWay}"/>
           <telerik:RadMaskedDateTimeInput
                                           IsClearButtonVisible="False"
                                           FormatString="{}{0:M/d/yy}"
                                           SelectionOnFocus="SelectAll"
                                           Value="{Binding SelectedDate, Mode=TwoWay}"/>
    </Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)

然后,我将直接在像这样的视图上调用它(如名称空间所示,它将位于GlobalUserControlDump项目中),一旦将名称空间添加到视图中,它就会按预期在智能感知中正常显示;

<UserControl 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    x:Class="My.Project.Views.RandomView" 
    xmlns:Controls="clr-namespace:My.Project.Controls;assembly=My.Project.GlobalUserControlDump"
    mc:Ignorable="d">

    <Grid>
            <Controls:DatePicker />
    </Grid>
 </UserControl>
Run Code Online (Sandbox Code Playgroud)

然后,通过所需的属性进行公开;

namespace My
{
    public partial class DatePicker : UserControl
    {
        public static readonly DependencyProperty SelectedDateProperty =
            DependencyProperty.Register("SelectedDate", typeof(DateTime), typeof(DatePicker), new PropertyMetadata(null));

        public …
Run Code Online (Sandbox Code Playgroud)

c# silverlight xaml user-controls caliburn.micro

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

无法在Silverlight DataGrid列中应用字符串格式

我有一个数据网格.其Item源设置为List.我的问题是Iam无法应用字符串格式.这是我尝试过的格式.我错过了什么吗?StringFormat ='MM/dd/yyyy'BtringFormat = {0:dd-MMM-yyyy}

附加结果网格

                        <sdk:DataGridTemplateColumn   Header="Recieved Date" Width="Auto"  >
                            <sdk:DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Path=RecievedDate, StringFormat=\{0:dd-MMM-yyyy\} }" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellTemplate>
                            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                                <DataTemplate>
                                    <sdk:DatePicker Name="dtpFinancialAndComplianceLog" Text="{Binding Path=RecievedDate,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                                </DataTemplate>
                            </sdk:DataGridTemplateColumn.CellEditingTemplate>
                        </sdk:DataGridTemplateColumn>
Run Code Online (Sandbox Code Playgroud)

.net c# format silverlight datagrid

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

如何在Windows Phone中更改滑块控件的高度?

它必须简单,但我无法弄清楚.如何在Windows Phone中更改滑块控件的高度?无论我为Height它设定多大的值,它仍然保持不变

<Slider Width="100" Height="600" />
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

c# silverlight xaml windows-phone-7

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