C
C#7mo 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.js77mo ago
How in C# I can edit this label ?
Dream
Dream7mo 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.js77mo 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
Dream
Dream7mo ago
np. If you use data-binding, You can solve perfect this problem. hang on. I will provide documentation.
Kaito.js7
Kaito.js77mo ago
Ok thx
Dream
Dream7mo ago
then if you don't understand, let me check your code and help you.
Kaito.js7
Kaito.js77mo ago
No description
Kaito.js7
Kaito.js77mo ago
In this pic DesrLabel is the name of the label ?
Kaito.js7
Kaito.js77mo ago
Like that ?
No description
Dream
Dream7mo ago
Yup. sure
Kaito.js7
Kaito.js77mo ago
So why I have an error ?
No description
Dream
Dream7mo ago
can I check?
Kaito.js7
Kaito.js77mo ago
This is saying Text is not null
Dream
Dream7mo ago
Can i check your project's code if the project have github repository?
Kaito.js7
Kaito.js77mo 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>
Dream
Dream7mo ago
send me C# file. only this part.
Kaito.js7
Kaito.js77mo 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";
}
}
}
Dream
Dream7mo ago
let me check.
Kaito.js7
Kaito.js77mo ago
So ?
Dream
Dream7mo ago
You can change Name to x:Name in XAML.
Kaito.js7
Kaito.js77mo ago
No description
Kaito.js7
Kaito.js77mo ago
No description
Dream
Dream7mo ago
Label's name.
Kaito.js7
Kaito.js77mo ago
Ho I forgot I change label in textblock to try something srry
Kaito.js7
Kaito.js77mo ago
No description
Dream
Dream7mo ago
Yup.
Kaito.js7
Kaito.js77mo ago
Same
No description
Dream
Dream7mo ago
You can try.
Kaito.js7
Kaito.js77mo ago
Tried I gave an error
Dream
Dream7mo ago
Can I see the error?
Kaito.js7
Kaito.js77mo ago
Translation : A reference is required for the proprierty, method or field not static "MaintWindow.tested"
No description
Dream
Dream7mo ago
sorry. i can't understand. I don't know about your language.
Kaito.js7
Kaito.js77mo ago
Ok np I translated ...
Kaito.js7
Kaito.js77mo ago
No description
Dream
Dream7mo ago
You can try to write the code in constitutor.
Kaito.js7
Kaito.js77mo ago
Constitutor ?
Dream
Dream7mo ago
in here.
No description
Kaito.js7
Kaito.js77mo ago
No description
Kaito.js7
Kaito.js77mo ago
Working So how can I do to make it possible on my function ?
Dream
Dream7mo ago
you can make the function to public. and then you can try.
Kaito.js7
Kaito.js77mo ago
Ho thx
Dream
Dream7mo ago
and you have to delete static.
Kaito.js7
Kaito.js77mo ago
Yeah I know Thx
Dream
Dream7mo ago
welcome.\ If you have any qestion, you can contact me at the anytime. for it, you can send DM. okay?
Kaito.js7
Kaito.js77mo ago
Ok thxx
Dream
Dream7mo 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.js77mo ago
Send me the Doc plz A bit
SinFluxx
SinFluxx7mo 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.js77mo 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
Dream
Dream7mo ago
?
Kaito.js7
Kaito.js77mo ago
I talk to @SinFluxx