Posts

Showing posts with the label static

Textbox not updating when static object method to update property is called

Image
Clash Royale CLAN TAG #URR8PPP Textbox not updating when static object method to update property is called First, let me state I am new to C# altogether. At the moment I am working on a program, and have been trying to get something that I thought would be rather simple to do. This is apparently not the case. I'll show here a very small example of what I have been trying to do. This is functionally identical, but without all the extra things that I have in the real project. We have 3 files here. MainWindow.xaml <Window.Resources> <CollectionViewSource x:Key="data1ViewSource" d:DesignSource="{d:DesignInstance {x:Type local:Data1}, CreateList=True}"/> </Window.Resources> <Grid> <Button x:Name="TestButton" Content="Button" HorizontalAlignment="Left" Margin="78,25,0,0" VerticalAlignment="Top" Width="75" Click="TestButton_Click"/> <TextBox x:Name="t...

Mark a method for static use

Image
Clash Royale CLAN TAG #URR8PPP Mark a method for static use How can I mark a method to use only if the class object was initialized as static? For example: public class A { public A() { } public void DoIt() { { public void DoItStatic() { } } public class B { private A _aa = new A(); private static A _aaStatic = new A(); public B() { } public void SomeMethod() { _aa.DoItStatic(); //Generate Error for that. _aaStatic.DoItStatic(); //it's fine { } So, if someone tries to use _aa.DoItStatic(), where _aa is not initialized as static, we generate an error. Is this possible? Thanks! You can't achieve that. – mjwills 16 mins ago So, there are no any options to make a check or anything else in class A? – BERKU...