标签: silverlight

如何在WP 7中使用gif动画图像

我看过这篇文章:在Silverlight的WP7应用程序中显示GIF

但就我而言?动画我正在使用弹出窗口.因此,当应用程序启动时,它会显示一个弹出窗口5秒钟.在这个弹出窗口中,我想显示一些.gif图像,但它不起作用.

这是我实现的代码:

    public partial class AnimatedSplashScreen : UserControl
    {
        protected Uri ImageSource
        {
            get;
            set;
        }
        public AnimatedSplashScreen()
        {
            InitializeComponent();
           ImageSource =
                new Uri(
                    "http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Sunflower_as_GIF.gif/200px-Sunflower_as_GIF.gif",
                    UriKind.Absolute);
            ImageTools.IO.Decoders.AddDecoder<GifDecoder>();

        }
Run Code Online (Sandbox Code Playgroud)

而xaml代码是:

<UserControl.Resources>

        <imagetools:ImageConverter x:Key="ImageConverter" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot"
          Width="480"
          Height="800"
          Background="White">
        <imagetools:AnimatedImage Source="{Binding ImageSource, Converter={StaticResource ImageConverter}}"  />
Run Code Online (Sandbox Code Playgroud)

但结果它不起作用,它显示一个空的背景.

更新:ImageTools.IO.Decoders.AddDecoder(); ImageSource = new Uri(" http://a3.twimg.com/profile_images/1136683647/hisoka_normal.gif ",UriKind.Absolute); 它仍然无法正常工作

c# silverlight silverlight-3.0 silverlight-4.0 windows-phone-7

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

在wcf ria服务中调用操作

我在wcf ria service.like中使用了一些调用操作方法,如下面的方法:

    [Invoke]
    public int GetCountOfAccountsByRequestId(long requestId)
    {
        return ObjectContext.Accounts.Count(a => a.RequestId ==requestId);
    }
Run Code Online (Sandbox Code Playgroud)

当我想从这个方法获取数据时,我使用以下代码运行并从invoke方法获取值:

        int countOfAccounts = 0;
        InvokeOperation<int> invokeOperation = context.GetCountOfAccountsByRequestId(selectedRequest.RequestId);

        invokeOperation.Completed += (s, args) =>
                                         {
                                             if (invokeOperation.HasError)
                                             {
                                                 var messageWindow = new MessageWindow(invokeOperation.Error.Message);
                                                 messageWindow.Show();
                                                 invokeOperation.MarkErrorAsHandled();
                                             }
                                             else
                                             {
                                                 countOfAccounts = invokeOperation.Value;


                                                 if (countOfAccounts == 0)
                                                 {

                                                     // do some thing

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

但是这个方法需要大量编码来运行invoke方法并从中获取值.此代码的一部分也是异步执行的.同样,某些方法必须串联实现.每个方法的返回值都与以前的方法有关. .

我该如何实现这个动作?!我怎么能写得比没有任何问题更好?

silverlight asynchronous invoke wcf-ria-services

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

ListBoxItem Horizo​​ntalContentAlignment =拉伸不起作用

我无法将列表框项目扩展到整个列表框宽度.

下面是我的列表框的xaml

<ListBox x:Name="MyListBox"
                 VerticalAlignment="Stretch"
                 HorizontalAlignment="Stretch"
                 HorizontalContentAlignment = "Stretch"
                 Margin="0,10,0,0"
                 ItemsSource="{Binding Path=Users}"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 Grid.Column="0"
                 Grid.ColumnSpan="1"
                 Grid.Row="1"
                 Grid.RowSpan="3">                      
        <ListBox.ItemTemplate>
            <DataTemplate>
                <local:MyListBoxTemplate/>
            </DataTemplate>
        </ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)

我已尝试在其他帖子上找到以下建议,但他们没有为我工作:

  • 将ListBox的Horizo​​ntalContentAlignment设置为Stretch
  • 覆盖listboxitem的样式,即listbox xaml中ItemContainerStyle标签内的新样式(注意:我正在使用大都会导航主题)
  • 编辑CoreStyles.xaml中的DefaultListBoxItemStyle样式以包含Horizo​​ntalContentAlignmemt

是因为我正在为我的数据模板使用单独的xaml文件吗?或者我的数据模板有问题?有没有人对我还能尝试什么有任何建议?

我看到某处或许我可以将ListBoxItem Width绑定到ListBox的实际宽度?

我是新手,所以如果我错过了一些非常简单/明显的东西,我会提前道歉!

以下是我的数据模板:

<Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" ShowGridLines="True" Height="20">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="10*" />
        <ColumnDefinition Width="30*" />
        <ColumnDefinition Width="300*" />
        <ColumnDefinition Width="50*" />
        <ColumnDefinition Width="10*" />
    </Grid.ColumnDefinitions>
    <Image x:Name="TwitterImageIcon"
           Grid.Column="1" 
           Grid.ColumnSpan="1" 
           Source="{Binding Path=imageUrl}"
          />
    <StackPanel Orientation="Horizontal" Grid.Column="2" Grid.ColumnSpan="1" HorizontalAlignment="Stretch" >

        <TextBlock x:Name="TwitterUsernameTextBlock"
                   Text="{Binding Path=username,StringFormat='@\{0\}  '}"/>
        <TextBlock x:Name="TwitterFullNameTextBlock"
               Text="{Binding Path=fullname}"/>
    </StackPanel>


        <Button x:Name="InfoButton" …
Run Code Online (Sandbox Code Playgroud)

silverlight listbox datatemplate stretch listboxitem

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

具有多个ColorAnimations的Silverlight故事板

我很难弄清楚如何使用ColorAnimation沿着可见的颜色光谱更改椭圆的填充颜色.ColorAnimation将颜色混合在一起而不是沿着色谱移动,所以我想出了以下内容.

<Ellipse x:Name="indicatorEllipse" HorizontalAlignment="Right" VerticalAlignment="Center" Height="20" Width="20" Stroke="Black" Margin="0 0 5 0" >
<Ellipse.Resources>
    <Storyboard x:Name="indicatorStoryboard">
        <!-- Animate the fill color of the Ellipse from red to green over 100 seconds. -->
        <ColorAnimation BeginTime="00:00:00" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="Red" To="OrangeRed" Duration="0:00:14" />
        <ColorAnimation BeginTime="00:00:15" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="OrangeRed" To="Orange" Duration="0:00:14" />
        <ColorAnimation BeginTime="00:00:30" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="Orange" To="Yellow" Duration="0:00:30" />
        <ColorAnimation BeginTime="00:01:01" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="Yellow" To="YellowGreen" Duration="0:00:14" />
        <ColorAnimation BeginTime="00:01:16" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="YellowGreen" To="GreenYellow" Duration="0:00:14" />
        <ColorAnimation BeginTime="00:01:31" Storyboard.TargetName="indicatorColorBrush" 
Storyboard.TargetProperty="Color"
From="GreenYellow" To="Green" Duration="0:00:14" /> …
Run Code Online (Sandbox Code Playgroud)

.net c# silverlight xaml storyboard

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

墓碑工作,但我的应用程序需要吗?

我正在使用Codeplex 的Tombstone帮助器,我有点困惑,我认为它保存了应用程序控件的状态,即Textbox,我在我的应用程序的一个页面上使用代码而不在另一个页面上使用它,但是当我测试它时它只是保存两个页面中文本框的状态相同,没有Tombstone Helper的文本框在我测试它时会保持状态.我正在测试的方法是按下模拟器上的Windows徽标打开浏览器,然后按住后退按钮.

这是我用于墓碑的代码

protected override void OnNavigatingFrom(System.Windows.Navigation.NavigatingCancelEventArgs e)
{
    this.SaveState(e); 
}

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    this.RestoreState();
}
Run Code Online (Sandbox Code Playgroud)

如果你能帮助我,我将不胜感激

c# silverlight codeplex windows-phone-7 tombstoning

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

从MainPage_Loaded运行时,VisualTreeHelper.GetChildrenCount返回0

在我的WP7应用程序中,我正在使用这个man方法来查找TextBlocka ToggleButton. /sf/answers/123194641/

当我在应用程序运行时拨打电话时,它可以正常工作.
如果我尝试进行完全相同的调用MainPage_Loaded,则FindChild返回null.

这是简单的电话

TextBlock myText = FindChild<TextBlock>(myToggle, "toggleTitle");  
myText.Text = "Some text";
Run Code Online (Sandbox Code Playgroud)

它看起来像是因为VisualTreeHelper.GetChildrenCount返回0.

为什么在应用程序运行时它没有值而不是从MainPage_Loaded?是不是MainPage_Loaded要等到应用程序加载才开始发射事件?

谢谢

silverlight windows-phone-7

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

我的班级在序列化期间丢失了它的方法

什么是我的问题

从ASMX服务返回的对象在Silverlight应用程序中使用.类具有方法,但ASMX WebMethod的结果不显示对象的方法.

告诉我更多

这是我的课

public class Dog
{
      public string Name{get;set;}    
      public void Bark();
}
Run Code Online (Sandbox Code Playgroud)

这是WebMethod

[WebMethod]
public List<Dog> Findlabrador()
{
    blah blah blah
    return list_of_labrador;
}
Run Code Online (Sandbox Code Playgroud)

银光代码

void LabradorFetchCompleted(object sender, LabradorFetchCompletedEventArgs e)
{
  var list_of_labrador = e.Result;
  foreach(var labradorDog in list_of_labrador)
  {
      labradorDog.Bark();
      //** WTH my labrador can't BARK** Bark method is not shown in intellisense there is compilation error if i explicitly specify 
  }
}
Run Code Online (Sandbox Code Playgroud)

我是程序员而不是外行

好吧,嗯,让我说出你的话.以下是重现问题的步骤

  • 创建一个Silverlight应用程序项目(让VS创建网站来托管应用程序)

  • 创建一个Silverlight类库,在其中创建Dog类

  • 将Silverlight类库编译为assembly(Dog.dll)

  • Dog.dllsilverlight程序集的引用添加到silverlight应用程序项目中

  • 将WebService应用程序添加到项目中(DogService.asmx注意asmx …

c# silverlight web-services class asmx

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

Windows phone7 ListPicker

在我的windows phone7应用程序中,我必须使用类似于下拉列表控件的控件.所以我遇到了提出WP7工具包程序集的ListPicker.

我遇到的问题是,它与页面中的其他元素重叠.以下是界面的屏幕截图.

在此输入图像描述

当我单击ListPicker时,它会展开列表并允许我从中选择一个项目.但是当我选择一个项目时,它会点击下方显示的按钮.我可以做,ExpansionMode="FullScreenOnly"但它将进入全屏模式,因为列表选择器只有3项不是我想要的方式.

有没有人知道我可以让ListPicker扩展并从中选择一个而不会发生位于其下方的按钮点击.

编辑

我已经安装WP7 Tool kit for Silverlight并将dll添加到项目中作为参考Microsoft.Phone.Controls.Toolkit

XAML --->

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"


<toolkit:ListPicker Name="listPicker1"/>
Run Code Online (Sandbox Code Playgroud)

windows silverlight silverlight-4.0 windows-phone-7 windows-phone-7.1

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

使用collectionView Source进行LISTBOX分组

ListBoxCollectionView编程方式使用源分组:

喜欢

Task 1 (certain date)
Task 2 (certain date)
Task 3 (certain date)
Task 4 (certain date)
Run Code Online (Sandbox Code Playgroud)

Certain date1  
  Task 1
  Task 3  
Certain date2
  Task 2
  Task 4
Run Code Online (Sandbox Code Playgroud)

silverlight wpf wpf-controls windows-phone-7

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

列表框滚动到结束在Windows Phone 7中

我的wp7应用程序中有listbox.当一个项目被添加到它我希望我的滚动结束.

我试过这件事

var Selecteditem = listmy.Items[listmy.Items.Count - 1];
listmy.ScrollIntoView(Selecteditem);
listmy.UpdateLayout();
Run Code Online (Sandbox Code Playgroud)

但什么都没发生.还有其他办法吗?

c# silverlight xaml expression-blend windows-phone-7

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