CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: WPF Iteration

Threaded View

  1. #1
    Join Date
    Jan 2011
    Posts
    4

    WPF Iteration

    Hello,

    Using .net 4 & VS C# Express 2010, new to both and I'm working through some basic programming tasks.

    I'm trying to have a while loop count disaplyed in my WFP textbox which is easy enough to do in a wpf console.

    Here's my code and xaml:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;

    namespace WpfWhileLoop
    {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
    public MainWindow()
    {
    InitializeComponent();

    int n = 1;

    while (n < 6)
    {
    textBox1.Text = "current value of n is " + n++;
    }
    }
    }
    }


    <Window x:Class="WpfWhileLoop.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
    <Grid>
    <TextBox Height="311" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="503" AcceptsReturn="True" />
    </Grid>
    </Window>

    When I run this I get:

    current value of n is 5

    I 'm trying to have each increment displayed, e.g.:

    current value of n is 1
    current value of n is 2
    current value of n is 3
    current value of n is 4
    current value of n is 5

    Any ideas how i can make this work?

    Thanks!
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)