C
C#13mo ago
Kaito.js7

How do I modify a label on my XAML code With a C# Function ?

Hi, I have a label with some data and I want to edit it when I launch my function
No description
52 Replies
Kaito.js7
Kaito.js7OP13mo ago
How in C# I can edit this label ?
Farhan Rizal
Farhan Rizal13mo ago
You can use data binding. are you using WPF? If you are using WPF, this is no problem. How do you think about it?
Kaito.js7
Kaito.js7OP13mo ago
Yes Yeah but idk how to do Like I have to the the name of my label.Text = "What I want"; Idk how to edit my text
Farhan Rizal
Farhan Rizal13mo ago
np. If you use data-binding, You can solve perfect this problem. hang on. I will provide documentation.
Kaito.js7
Kaito.js7OP13mo ago
Ok thx
Farhan Rizal
Farhan Rizal13mo ago
then if you don't understand, let me check your code and help you.
Kaito.js7
Kaito.js7OP13mo ago
No description
Kaito.js7
Kaito.js7OP13mo ago
In this pic DesrLabel is the name of the label ?
Kaito.js7
Kaito.js7OP13mo ago
Like that ?
No description
Farhan Rizal
Farhan Rizal13mo ago
Yup. sure
Kaito.js7
Kaito.js7OP13mo ago
So why I have an error ?
No description
Farhan Rizal
Farhan Rizal13mo ago
can I check?
Kaito.js7
Kaito.js7OP13mo ago
This is saying Text is not null
Farhan Rizal
Farhan Rizal13mo ago
Can i check your project's code if the project have github repository?
Kaito.js7
Kaito.js7OP13mo ago
That's a private project I'll edit it to left only the important part So the XAML
<Window x:Class="ToxicMenuWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ToxicMenuWPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<CheckBox>Aimbot</CheckBox>
<CheckBox Margin="0,25,0,0">XA</CheckBox>
<CheckBox Margin="0,50,0,0">WD</CheckBox>
<Label Name="tested" Margin="0,100,0,0"></Label>
</Grid>
</Window>
<Window x:Class="ToxicMenuWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ToxicMenuWPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<CheckBox>Aimbot</CheckBox>
<CheckBox Margin="0,25,0,0">XA</CheckBox>
<CheckBox Margin="0,50,0,0">WD</CheckBox>
<Label Name="tested" Margin="0,100,0,0"></Label>
</Grid>
</Window>
Farhan Rizal
Farhan Rizal13mo ago
send me C# file. only this part.
Kaito.js7
Kaito.js7OP13mo ago
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Threading;
using System.Windows.Forms;
using Memory;
using System.Buffers;
using Swed32;
using Microsoft.VisualBasic.Devices;
using System.Security.Cryptography.Xml;
using System.Numerics;
using System.Threading.Tasks;
using ToxicMenuWPF.Helpers;
using ToxicMenuWPF.Models;
using ToxicMenuWPF.src;

namespace ToxicMenuWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
[DllImport("user32.dll")]

static extern short GetAsyncKeyState(Keys vK);

public MainWindow()
{
InitializeComponent();

Menu_Exec();
}

static void Menu_Exec()
{
tested.Content = "Test";
}
}
}
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Threading;
using System.Windows.Forms;
using Memory;
using System.Buffers;
using Swed32;
using Microsoft.VisualBasic.Devices;
using System.Security.Cryptography.Xml;
using System.Numerics;
using System.Threading.Tasks;
using ToxicMenuWPF.Helpers;
using ToxicMenuWPF.Models;
using ToxicMenuWPF.src;

namespace ToxicMenuWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : Window
{
[DllImport("user32.dll")]

static extern short GetAsyncKeyState(Keys vK);

public MainWindow()
{
InitializeComponent();

Menu_Exec();
}

static void Menu_Exec()
{
tested.Content = "Test";
}
}
}
Farhan Rizal
Farhan Rizal13mo ago
let me check.
Kaito.js7
Kaito.js7OP13mo ago
So ?
Farhan Rizal
Farhan Rizal13mo ago
You can change Name to x:Name in XAML.
Kaito.js7
Kaito.js7OP13mo ago
No description
Kaito.js7
Kaito.js7OP13mo ago
No description
Farhan Rizal
Farhan Rizal13mo ago
Label's name.
Kaito.js7
Kaito.js7OP13mo ago
Ho I forgot I change label in textblock to try something srry
Kaito.js7
Kaito.js7OP13mo ago
No description
Farhan Rizal
Farhan Rizal13mo ago
Yup.
Kaito.js7
Kaito.js7OP13mo ago
Same
No description
Farhan Rizal
Farhan Rizal13mo ago
You can try.
Kaito.js7
Kaito.js7OP13mo ago
Tried I gave an error
Farhan Rizal
Farhan Rizal13mo ago
Can I see the error?
Kaito.js7
Kaito.js7OP13mo ago
Translation : A reference is required for the proprierty, method or field not static "MaintWindow.tested"
No description
Farhan Rizal
Farhan Rizal13mo ago
sorry. i can't understand. I don't know about your language.
Kaito.js7
Kaito.js7OP13mo ago
Ok np I translated ...
Kaito.js7
Kaito.js7OP13mo ago
No description
Farhan Rizal
Farhan Rizal13mo ago
You can try to write the code in constitutor.
Kaito.js7
Kaito.js7OP13mo ago
Constitutor ?
Farhan Rizal
Farhan Rizal13mo ago
in here.
No description
Kaito.js7
Kaito.js7OP13mo ago
No description
Kaito.js7
Kaito.js7OP13mo ago
Working So how can I do to make it possible on my function ?
Farhan Rizal
Farhan Rizal13mo ago
you can make the function to public. and then you can try.
Kaito.js7
Kaito.js7OP13mo ago
Ho thx
Farhan Rizal
Farhan Rizal13mo ago
and you have to delete static.
Kaito.js7
Kaito.js7OP13mo ago
Yeah I know Thx
Farhan Rizal
Farhan Rizal13mo ago
welcome.\ If you have any qestion, you can contact me at the anytime. for it, you can send DM. okay?
Kaito.js7
Kaito.js7OP13mo ago
Ok thxx
Farhan Rizal
Farhan Rizal13mo ago
But I think, You have to use data binding in modern projects. that's good. All of project with WPF are using MVVM pattern. Did you know about it?
Kaito.js7
Kaito.js7OP13mo ago
Send me the Doc plz A bit
SinFluxx
SinFluxx13mo ago
You said send you the docs, that's a search for the docs, learning to search for documentation is an important skill
Kaito.js7
Kaito.js7OP13mo ago
Wrong conv srry Yeah but before he said that he'll send me a doc so I was thinking about a more understandable doc not the microsoft doc I got it Here
Farhan Rizal
Farhan Rizal13mo ago
?
Kaito.js7
Kaito.js7OP13mo ago
I talk to @SinFluxx
Want results from more Discord servers?
Add your server