如何在xaml中显示我的图片文件夹

时间:2017-02-01 21:00:00

标签: c# wpf xaml

我在这个网站上是新手,我从一些样本中提取的Kinect代码有太多麻烦。我想要做的是在public class NewScheduleActivity extends AppCompatActivity { ImageView image1, image2, image3, image4, image5, image6, image7, image8, image9, image10; ImageView activityslotlocation1a, activityslotlocation1b, activityslotlocation1c, activityslotlocation1d, activityslotlocation1e; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.newschedulescreen); image1 = (ImageView) findViewById(R.id.imageView1); image2 = (ImageView) findViewById(R.id.imageView2); image3 = (ImageView) findViewById(R.id.imageView3); image4 = (ImageView) findViewById(R.id.imageView4); image5 = (ImageView) findViewById(R.id.imageView5); image6 = (ImageView) findViewById(R.id.imageView6); image7 = (ImageView) findViewById(R.id.imageView7); image8 = (ImageView) findViewById(R.id.imageView8); image9 = (ImageView) findViewById(R.id.imageView9); image10 = (ImageView) findViewById(R.id.imageView10); activityslotlocation1a = (ImageView) findViewById(R.id.activityslot1a); activityslotlocation1b = (ImageView) findViewById(R.id.activityslot1b); activityslotlocation1c = (ImageView) findViewById(R.id.activityslot1c); activityslotlocation1d = (ImageView) findViewById(R.id.activityslot1d); activityslotlocation1e = (ImageView) findViewById(R.id.activityslot1e); image1.setOnLongClickListener(longClickListener); image2.setOnLongClickListener(longClickListener); image3.setOnLongClickListener(longClickListener); image4.setOnLongClickListener(longClickListener); image5.setOnLongClickListener(longClickListener); image6.setOnLongClickListener(longClickListener); image7.setOnLongClickListener(longClickListener); image8.setOnLongClickListener(longClickListener); image9.setOnLongClickListener(longClickListener); image10.setOnLongClickListener(longClickListener); activityslotlocation1a.setOnDragListener(dragListener); activityslotlocation1b.setOnDragListener(dragListener); activityslotlocation1c.setOnDragListener(dragListener); activityslotlocation1d.setOnDragListener(dragListener); activityslotlocation1e.setOnDragListener(dragListener); } View.OnLongClickListener longClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ClipData data = ClipData.newPlainText("", ""); View.DragShadowBuilder myShadowBuilder = new View.DragShadowBuilder(v); v.startDragAndDrop(data, myShadowBuilder, v, 0); return true; } }; View.OnDragListener dragListener = new View.OnDragListener() { @Override public boolean onDrag(View v, DragEvent event) { int dragEvent = event.getAction(); final View view = (View) event.getLocalState(); switch (dragEvent) { case DragEvent.ACTION_DRAG_ENTERED: break; case DragEvent.ACTION_DRAG_EXITED: break; case DragEvent.ACTION_DROP: // Location 1A if (view.getId() == R.id.imageView1) { activityslotlocation1a.setImageResource(R.drawable.art); } else if (view.getId() == R.id.imageView2) { activityslotlocation1a.setImageResource(R.drawable.gohome); } else if (view.getId() == R.id.imageView3) { activityslotlocation1a.setImageResource(R.drawable.bedtime); } else if (view.getId() == R.id.imageView4) { activityslotlocation1a.setImageResource(R.drawable.watchamovie); } else if (view.getId() == R.id.imageView5) { activityslotlocation1a.setImageResource(R.drawable.swimmingclass); } else if (view.getId() == R.id.imageView6) { activityslotlocation1a.setImageResource(R.drawable.cooking); } else if (view.getId() == R.id.imageView7) { activityslotlocation1a.setImageResource(R.drawable.blocks); } else if (view.getId() == R.id.imageView8) { activityslotlocation1a.setImageResource(R.drawable.drink); } else if (view.getId() == R.id.imageView9) { activityslotlocation1a.setImageResource(R.drawable.bedtimestory); } else if (view.getId() == R.id.imageView10) { activityslotlocation1a.setImageResource(R.drawable.pizzanight); } //view.animate() //.x(activityslotlocation1a.getX()) //.y(activityslotlocation1a.getY()) //.setDuration(500) //.start(); MediaPlayer mymedia = MediaPlayer.create(NewScheduleActivity.this,R.raw.whoosh); mymedia.start(); break; } return true; } }; 中显示我的图片文件夹中的图片,就像在SlideShow示例中一样,但我不想用幻灯片更改图片。我想用语音命令改变它们。问题是当我从SlideShow中复制粘贴代码时,图片不会显示出来。

XAML

XAML

XAML.CS

<Grid Row="1">
    <Image x:Name="next" Source="{Binding NextPicture}" Opacity="0"/>
    <Image x:Name="previous" Source="{Binding PreviousPicture}" Opacity="0"/>
    <Image x:Name="current" Source="{Binding Picture}"/>
</Grid>

0 个答案:

没有答案