Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Windows phone应用程序更改透视页面项目的颜色偶数_C#_Windows Phone 8.1 - Fatal编程技术网

C# Windows phone应用程序更改透视页面项目的颜色偶数

C# Windows phone应用程序更改透视页面项目的颜色偶数,c#,windows-phone-8.1,C#,Windows Phone 8.1,我已经构建了Windows phone应用程序,现在我想在奇偶项目的基础上更改透视页面项目的颜色。 这怎么可能?任何解决方案都将不胜感激 下面是一些代码示例: <PivotItem x:Uid="PivotItem1" Margin="19,152,0,-29.5" Header="Inbox" CommonNavigationTransitionInfo.IsStaggerElement="T

我已经构建了Windows phone应用程序,现在我想在奇偶项目的基础上更改透视页面项目的颜色。 这怎么可能?任何解决方案都将不胜感激

下面是一些代码示例:

<PivotItem
            x:Uid="PivotItem1"
            Margin="19,152,0,-29.5"
            Header="Inbox"
            CommonNavigationTransitionInfo.IsStaggerElement="True">
            <ListView x:Name="myInbox"
                IsItemClickEnabled="True"
                ItemClick="ItemView_ItemClick"
                ContinuumNavigationTransitionInfo.ExitElementContainer="True" FontSize="36" Margin="-18,-139,-0.167,55.333">
                <ListView.ItemTemplate>

                    <DataTemplate>

                        <Grid >

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="4*"/>

                                <ColumnDefinition Width="1*" />

                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition MinHeight="30" />
                            </Grid.RowDefinitions>

                            <TextBlock Grid.Column="0" TextWrapping="NoWrap" Text="{Binding Subject}" FontSize="22" Grid.Row="0"></TextBlock>
                            <TextBlock Grid.Column="1" TextAlignment="Right" TextWrapping="NoWrap" Text="{Binding Date}" Grid.Row="0"></TextBlock>
                        </Grid>

                    </DataTemplate>
                </ListView.ItemTemplate>

            </ListView>
        </PivotItem>
电子邮件管理器电子邮件收件箱代码

class EmailManager
{
    public static List<EmailMessage> EmailInbox;


 public EmailManager(){
   EmaiInbox.Add(new EmailMessage { Id = 1, Subject = "my email subject one with long long text header", Date = "12-Dec-2015 05:10", Contents = "Following the comments on the question, one possible answer would be to suscribe to the Loaded event of your page and call the Event method from there.", Sender = "abc@example.com" });
            EmaiInbox.Add(new EmailMessage { Id = 2, Subject = "my email subject 2", Date = "12-Dec-2015 07:25", Contents = "Following the comments on the question, one possible answer would be to suscribe to the Loaded event of your page and call the Event method from there.", Sender = "abc@example.com" });
 }

}
类电子邮件管理器
{
公共静态列表电子邮件收件箱;
公共电子邮件管理器(){
EmaiInbox.Add(新的EmailMessage{Id=1,Subject=“我的电子邮件主题之一,带有长文本标题”,Date=“12-Dec-2015 05:10”,Contents=“根据对该问题的评论,一个可能的答案是订阅页面的加载事件并从那里调用事件方法。”,Sender=”abc@example.com" });
EmaiInbox.Add(新的EmailMessage{Id=2,Subject=“我的电子邮件Subject 2”,Date=“12-Dec-2015 07:25”,Contents=“在对这个问题的评论之后,一个可能的答案是订阅页面加载的事件并从那里调用事件方法。”,Sender=”abc@example.com" });
}
}

好的,我得到了解决方案,想与大家分享

如果要更改列表的前景色,只需使用以下选项:

yourlist.Foreground=新的SolidColorBrush(Colors.Red)

在矿山代码中:

else
    {
        LoadInbox(myInbox);                   
         /// myInbox.Background = new SolidColorBrush(Colors.Red);
          myInbox.Foreground = new SolidColorBrush(Colors.Red);
          myOutbox.Foreground = new SolidColorBrush(Colors.Red);
     }
您还可以通过以下方式更改网格子项的颜色:

public YourConstructor() // replace YourConstructor with your class name.
    {
        this.InitializeComponent();

        this.navigationHelper = new NavigationHelper(this);
        this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
        this.navigationHelper.SaveState += this.NavigationHelper_SaveState;


        foreach (var c in ContentRoot.Children)
        {
            if (c.GetType() == typeof(TextBlock))
            {
                var c1 = c as TextBlock;
                c1.Foreground = new SolidColorBrush(Colors.Red);                  
            }

        }
    }
ContentRoot是页面的网格

public YourConstructor() // replace YourConstructor with your class name.
    {
        this.InitializeComponent();

        this.navigationHelper = new NavigationHelper(this);
        this.navigationHelper.LoadState += this.NavigationHelper_LoadState;
        this.navigationHelper.SaveState += this.NavigationHelper_SaveState;


        foreach (var c in ContentRoot.Children)
        {
            if (c.GetType() == typeof(TextBlock))
            {
                var c1 = c as TextBlock;
                c1.Foreground = new SolidColorBrush(Colors.Red);                  
            }

        }
    }