iskander
iskander
CC#
Created by iskander on 1/19/2024 in #help
✅ (Avalonia) i dont get data binding
so im following the official tutorial on how to make a simple to-do app with avalonia. everything is fine and dandy but for whatever reason, trying to add a data context doesnt display my hardcoded values i set!
//MainWindow.axaml
<Window //boiler plate stuff
x:DataType="vm:MainWindowViewModel"
x:Class="testAvaloniaApplication1.Views.MainWindow"
Title="Iskander's great and grand TO-DO list">

<Views:ToDoListView DataContext="{Binding ToDoList}"/>

</Window>
//MainWindow.axaml
<Window //boiler plate stuff
x:DataType="vm:MainWindowViewModel"
x:Class="testAvaloniaApplication1.Views.MainWindow"
Title="Iskander's great and grand TO-DO list">

<Views:ToDoListView DataContext="{Binding ToDoList}"/>

</Window>
7 replies
CC#
Created by iskander on 11/16/2023 in #help
adding an element to a VerticalStackLayout in c# doesnt work as expected
hi! so i wanted to add a visual element (in my case a ContentView) to a VerticalStackLayout that i declared in the xaml file and exposed it via x:Name="Stack" i tried doing Stack.Add(MyView) in the cs file, it did add it, i checked the "count" variable in the stack and it did increment but it is not visible. when i resize the window the elements pops into existence. obviously i'd love it if it did render without needing to resize 😅
2 replies
CC#
Created by iskander on 8/8/2023 in #help
✅ TcpClient is connected to TcpListener but TcpListener isn't connected...
so this is how i accept clients which passes through with no issues. i've made to sure to catch any errors that could result from function and none is thrown...
public static async Task<bool> AcceptClient(CancellationToken Token)
{
if (!IsServer())
{
return false;
}
Server.Start();
TcpClient JoinedClient = await Server.AcceptTcpClientAsync(Token);
Server.Stop();

if (JoinedClient != null)
{
Clients.Add(JoinedClient);
return true;
}
else
{
return false;
}
}
public static async Task<bool> AcceptClient(CancellationToken Token)
{
if (!IsServer())
{
return false;
}
Server.Start();
TcpClient JoinedClient = await Server.AcceptTcpClientAsync(Token);
Server.Stop();

if (JoinedClient != null)
{
Clients.Add(JoinedClient);
return true;
}
else
{
return false;
}
}
this is how the client attempts to connect to the server. this result in a successful connection.
public static async Task<bool> JoinServer(string IpAddress)
{
Client = new TcpClient();

if (IPEndPoint.TryParse(IpAddress, out IPEndPoint Result))
{
Result.Port = Port;
await Client.ConnectAsync(Result);
return true;
}
else
{
Client = null;
return false;
}
}
public static async Task<bool> JoinServer(string IpAddress)
{
Client = new TcpClient();

if (IPEndPoint.TryParse(IpAddress, out IPEndPoint Result))
{
Result.Port = Port;
await Client.ConnectAsync(Result);
return true;
}
else
{
Client = null;
return false;
}
}
my pc is the server while my phone is the client. they're in the same network but i havent touched the firewall settings in my pc yet but i assume that wont cause this issue...
26 replies
CC#
Created by iskander on 8/7/2023 in #help
❔ ✅ (SOLVED) TcpListener.AcceptTcpClientAsync does not get cancelled
CancellationTokenSource cancel = new(400);

TcpClient JoinedClient = await Server.AcceptTcpClientAsync(cancel.Token);
CancellationTokenSource cancel = new(400);

TcpClient JoinedClient = await Server.AcceptTcpClientAsync(cancel.Token);
so i expect this code to accept any tcp clients and if a 400ms period pass it will cancel but for whatever reason AcceptTcpClientAsync keeps halting my execution! i could probably run my own wait timer and if the timer finishes then i will call TcpListener.Stop() but i can see how that workaround would cause issues for in the future. and one odd thing is when a tcp client successfully connects to the server the function doesnt finish execution oddly
16 replies