Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.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 8.1:将远程映像添加到底部AppBar或AppBarButton_C#_Xaml_Windows Phone 8_Windows Phone 8.1_Windows Phone 7.1 - Fatal编程技术网

C# Windows Phone 8.1:将远程映像添加到底部AppBar或AppBarButton

C# Windows Phone 8.1:将远程映像添加到底部AppBar或AppBarButton,c#,xaml,windows-phone-8,windows-phone-8.1,windows-phone-7.1,C#,Xaml,Windows Phone 8,Windows Phone 8.1,Windows Phone 7.1,我想将远程图像添加到应用程序栏按钮。 我的图像就是这个url 我想从后端将它绑定到appbarbutton。我的后端代码是propic.UriSource=newuri(“http://2.bp.blogspot.com/-yEbb9_qp-jg/U8-KGeZAy3I/AAAAAAAAB0U/m91Bv1jPAQI/s1600/india+赢+在+上议院.jpg“ 但我的后端代码不工作…有人请告诉我怎么做 <AppBarButton Label="Ride Now

我想将远程图像添加到应用程序栏按钮。 我的图像就是这个url 我想从后端将它绑定到appbarbutton。我的后端代码是
propic.UriSource=newuri(“http://2.bp.blogspot.com/-yEbb9_qp-jg/U8-KGeZAy3I/AAAAAAAAB0U/m91Bv1jPAQI/s1600/india+赢+在+上议院.jpg“
但我的后端代码不工作…有人请告诉我怎么做

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
下面是我的Xaml代码

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

你不能给AppBar图像提供一个绝对的Uri,AppBarButtons就是不能这样工作

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
你可以下载你的图像,保存到本地存储,然后从那里以图像的形式读取。别忘了你的图像需要遵循大小调整格式

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
你可以在这里获得更多的信息

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
下面的代码将帮助您

            <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic" Height="100" Width="100"/>
                </AppBarButton.Icon>
            </AppBarButton>
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="Ride Now">
                <AppBarButton.Icon>

                    <BitmapIcon x:Name="propic12" Height="100" Width="100"/>
                </AppBarButton.Icon>   
                </AppBarButton>
                <AppBarButton Label="x" Icon="Admin" />
                </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>
using (var htc = new HttpClient())
{
    var file = await htc.GetStreamAsync("Your image url");
    if (!isoStore.FileExists("shared/shellcontent/appbarimage.png"))
    {
        using (IsolatedStorageFileStream fileStream = isoStore.OpenFile("shared/shellcontent/appbarimage.png", FileMode.Create))
        {
            await file.CopyToAsync(fileStream);
        }
    }
}

propic.UriSource = new Uri("isostore:/Shared/ShellContent/appbarimage.png",UriKind.Relative);

它说isoStore在当前上下文中不存在,而IsolatedStorageFileStream在当前上下文中不存在……实际上,windows.storage.IsolatedStorage仅在windowsphone8.1中工作