Leo*_*lho 5 c# xaml image xamarin xamarin.forms
我正在尝试更改ContentPage. I\xc2\xb4m 使用绑定上下文来执行此操作。但是,即使我更改模型视图中的源,这也不会更新我视图中的图像。
UpdateMethod()\n{\n imageSource1 = imageSource[1];\n}\n\npublic string ImageSource1\n{\n get\n {\n return imageSource1;\n }\n\n set\n {\n imageSource1 = value;\n this.Notify("ImageSource1");\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\nXAML:
\n\n<ContentView HorizontalOptions="Center" Grid.Row="0" >\n <Image ClassId = "1" Source="{Binding ImageSource1}" BindingContextChanged="Handle_BindingContextChanged">\n <Image.GestureRecognizers>\n <TapGestureRecognizer Command="{Binding OnTapGestureRecognizerTappedCommand1}" NumberOfTapsRequired="1" />\n </Image.GestureRecognizers>\n </Image> \n</ContentView>\nRun Code Online (Sandbox Code Playgroud)\n
当您绑定时,ImageSource请使用Xamarin.Forms.ImageSource作为属性的返回类型。或者您可以使用它的派生类,就像FileImageSource指定文件路径一样。还要确保该路径存在于本机项目中。
| 归档时间: |
|
| 查看次数: |
12347 次 |
| 最近记录: |