Will Pittenger
✅ Mystery errors that appear in build output but not the editor
I'm rather puzzled why the C# compiler reports these issues. They all appear to be bogus. No errors are listed in the C# editor. Some of the identifiers the compilers failed to find were classes that the C# editor not only found, but marked as classes with syntax highlighting. It doesn't report any errors there.
Does anyone have any ideas what's going on? I just checked code into https://github.com/ChatZilla-Replacement-Project/BestChat/tree/AvaloniaBrokenAXAML.
12 replies
CS0006 Can't find metadata dll, but paths are correct
I have a project,
BestChat.Prefs.GUI.Ctrls.csproj
which references the DLL project BestChat.Prefs.Data
. I'm getting the error shown below:
I don't understand why. The line from BestChat.Prefs.GUI.Ctrls.csproj
is <ProjectReference Include="..\BestChat.Prefs.Data\BestChat.Prefs.Data.csproj" />
. BestChat.Prefs.Data
is one directory up. So the relative path should be correct.
What's going on and how do I fix it?198 replies
Resource Explorer not updating .resx.cs file when I make changes
I have
Resources.resx
in my project. Prior to VS 2022 17.1.0, when I added resources to that RESX, Resources.resx.cs
was updated every time I saved. But not now. What's going on?17 replies
Abstract events implemented, but compiler warns they aren't used
I have an abstract class that declares abstract events that derived classes are required to implement. That allows owners of the class who have only a reference to the base type to subscribe to those events. But not all of the derived classes fire those events. Now the compiler is complaining those events aren't being used. Any suggestions on what I can do about those warnings?
11 replies
✅ How to deserialize JSON in .NET when my base class is generic?
I have a concrete class,
ClientEventInfo
derived from a generic. So I tried to deserialize a JSON file with System.Text.Json.JsonSerializer.Deserialize<ClientEventInfo>("url")
, but I get System.TypeInitializationException
. Seems the generic can't be initialized. Is there a way around it? I don't know what's going on here.14 replies
❔ Can't get root XAML element of UserControl for binding
I have a user control that declares a property that I need to bind properties of its children to. I was trying
"{Binding Property, ElementName=window}"
for my binding expression. But that seems to fail. It seems user controls don't have a window element. I tried {Binding Property, RelativeSource={RelativeSource AncestorType=UserControl, AncestorLevel=20}}
as well, but that doesn't work either. I don't know why. Can someone help? Technically, UserControl
isn't my immediate base class. So I tried the intermediate base class as well, but that didn't work. I also tried the derived class to no avail.6 replies
✅ How do you control which WPF property is the default for that class?
Examine the following XAML:
If
SomeClass
where derived from System.Windows.Controls.Control
, the property being set would be Content
. But in other WPF classes, it might be something like Text
. How do I specify my class's default property? The only thing I can find is for Windows Forms. Google happily found results for the default value, but I don't need that. I want the second example in the source above to resemble the first.
In this case, I am deriving from System.Windows.Controls.UserControl
, but as an abstract
class. I don't want the derived class setting Content
as that would mess up the base class.3 replies
❔ ✅ WPF Class derivation where both classes have XAML pages
Is it OK for base WPF class to have a XAML page and its derived class to also declare one? So we'd have
X
deriving from Y
with the following files existing: x.xaml.cs, x.xaml, y.xaml.cs, and y.xaml.5 replies
✅ Abstract classes as the WPF DesignContext?
Does it matter if the value in
d:DesignContext="{d:DesignInstance Type=X}"
is an abstract
class. I can't get the WPF design to acknowledge my type. I know some of you guys have said not to rely on it, but it does help from time to time and I at least like the design context set. I've tried deleting the bin and obj folders for that project and restarting VS. Didn't help.
Then inside BestChat.Platform.Conversations.dll, we have BestChat.Platform.Conversations.AbstractConversation
. Those appear to match to me.
34 replies
✅ Null check not enough to safely convert from nullable enum
I have a class declaring an
enum
and a nullable value for that enum
:
I then try to reference that field from a second class:
Yet even with the null check, the IDE is insisting that smt
could be null
and won't let me use the value:
What's going on?28 replies
✅ WPF Custom control should have contents as DockPanel, but it shows up at runtime as ScrollViewer
I have a
UserControl
I'm implementing with the source shown below. When I check my custom controls Content
property, the value is a ScrollViewer
. What's going on? I expected a DockPanel
.
9 replies
✅ WPF MouseOver expansion of item isn't working
I have a window with a bar that needs to hide down to a separator until the user mouses over it or checks a checkbox (which pins the bar to "open"). However, WPF seems to be claiming if the mouse is over the margin for the separator, it's not over the bar. The code is below.
What's going on? It should work so that the bar stays open if the mouse is anywhere over the bar, not just the separator.
16 replies
✅ WPF trees with some items that can't be selected
I'm building a UI with a tree view where some items exist only to group children. The tree will function as a kind of vertical tree control. When most items in the tree are selected, I'll show a control next to the tree. But the items that are only groups don't have a control to show. So I don't want to allow their selection.
How do I pull that off?
80 replies
✅ WPF TreeView only shows icon and only for the root item
have a tree declared with the following XAML and added from code behind a single item for the root. The root item does have children and a name for each item. But nothing appears beyond a single icon. XAML is reporting no binding failures. I've put breakpoints in for the
Children
, LocalizedName
, and LocalizedLongDesc
properties, but of those, only Children
is called. What's going on?
2 replies
✅ VS seems to be ignore .gitignore when adding files to a repository
I was browsing files inside my project's repository Best-Chat (on GitHub). While in there, I noticed files that should've been excluded. These include the
.vs
folder and all bin
and obj
folder. Any ideas what's going on?8 replies
✅ Representing an ongoing conversation in XAML and recording it
I'm working on an application in WPF that will show on going conversations much like what you see here. The conversation could go back in history infinitely far back in time (or at least to when it started). I also want to save it to a file. As posts in the conversation get older, it might be worth allowing garbage collection to remove them from memory until the user tries to scroll that far back.
I also want a log file for the user to browse and search, if desired, with tools like GREP or PowerShell. Unfortunately, I don't think a human readable format will store enough information. So I may need a JSON log as well that I'd reload conversations from.
All this needs to be shown with XAML. If the conversation is too short, I'd like some filler for the space above (below?) the existing posts until the posts fill the window.
Any suggestions on how to implement that?
63 replies
❔ XDG0031 can't find resource in assembly
I have a pair of derived WPF comboboxes for which I'm getting an error that I can't figure out how to resolve. See below. I suspect the error was from the WPF designer and not a compiler. Can someone explain what I can do? I found nothing on Google.
2 replies
✅ How do I specify custom base class for user control?
I declared a custom base class derived from
UserControl
. Now in a second assembly, I need to derive from that. The base class doesn't provide a XAML page. Instead, the derived class would. So MyCtrl
is derived from MyCtrlBase
which in turn derives from UserControl
. How do I specify that in the XAML? I tried the following, but it didn't work. Seems the designer doesn't see my custom base class.
Can someone tell me what I need to change?2 replies