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

Thread: WPF Iteration

Threaded View

  1. #1
    Join Date
    Jan 2011

    WPF Iteration


    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()

    int n = 1;

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

    <Window x:Class="WpfWhileLoop.MainWindow"
    Title="MainWindow" Height="350" Width="525">
    <TextBox Height="311" HorizontalAlignment="Left" Name="textBox1" VerticalAlignment="Top" Width="503" AcceptsReturn="True" />

    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?

    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)