Label Creation

Hello

I am new to .net programming in visual components, and wants to learn. Hence I want to create a panel for weld parameters with a label that changes the text. I have created a button which works and I have a created labels, but i cannot change the text inside the label via the code from the button.

I have done the turtorial for the Hello world panel, which creates a box in the layout.

Any help would be apreciated.

You could check if there is relevant content in the Academy for .NET programming. There should at least be one course that is helpful, and some additional lessons.

Hi

I have been through the tutorials for .net, but i cannot find a way to change the text of a label inside the panel. I want to do something along what is done 11 minutes inside this video:

C# Tutorial - How to Display a Value from TextBox as Label Output - YouTube

Hello. I hope all is well.

An easy way is to use Caliburn.Micro library and have the text box, button and label in your view use the same name as the properties and methods in your view model to make the binding easy. Here is a quick and dirty example, and notice that I notified property update (pick and choose how you want to do that).


View Model

    [Export(typeof(IPlugin))]
    [Export(typeof(IDockableScreen))]
    public class LabelViewModel : DockableScreen, IPlugin
    {
        public void Exit()
        {
        }

        public void Initialize()
        {
        }

        public LabelViewModel(): base()
        {
            this.DisplayName = "Test";
            this.DisplayText = "Bob";
            this.TestText = "Lil Boozie";
        }

        private string _testText { get; set; }
        public string TestText
        {
            get { return _testText; }
            set { _testText = value;
                NotifyOfPropertyChange(() => TestText);

            }
        }

        private string _displayText { get; set; }
        public string DisplayText
        {
            get { return _displayText; }
            private set { _displayText = value;
                NotifyOfPropertyChange(() => DisplayText);

            }
        }

        public void UpdateText()
        {
            this.DisplayText = this.TestText;
        }
    }

View

    <Grid>
        <TextBox x:Name="TestText" HorizontalAlignment="Left" Height="36" Margin="46,32,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="150"/>
        <Button x:Name="UpdateText" Content="Button" HorizontalAlignment="Left" Height="34" Margin="46,90,0,0" VerticalAlignment="Top" Width="150"/>
        <Label x:Name="DisplayText" Foreground="HotPink" FontSize="24" Content="Label" HorizontalAlignment="Left" Margin="46,159,0,0" VerticalAlignment="Top" Height="39" Width="150"/>
    </Grid>

Clean it up, think of other way, perhaps others share. Just keep in mind or learn more about bindings and things you can do.

        private string _testText;
        public string TestText
        {
            get { return _testText; }
            set { _testText = value;            }
        }

        private string _displayText;
        public string DisplayText
        {
            get { return _displayText; }
            private set { _displayText = value;}
        }

        public void UpdateText()
        {
            _displayText = _testText;
            NotifyOfPropertyChange(("DisplayText"));
        }

Hello Zesty

Thank you so much for the help, It works like i imagined.