Will Pittenger
Will Pittenger
CC#
Created by Will Pittenger on 9/19/2024 in #help
✅ 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
CC#
Created by Will Pittenger on 8/27/2024 in #help
✅ My RESX file still is supposedly invalid
No description
5 replies
CC#
Created by Will Pittenger on 8/18/2024 in #help
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:
Error (active) CS0006 Metadata file 'B:\Contents\Best Chat\Code\BestChat.Prefs.Data\bin\Debug\net8.0-windows\BestChat.Prefs.Data.dll' could not be found BestChat.Prefs.GUI.Ctrls B:\Contents\Best Chat\Code\BestChat.Prefs.GUI.Ctrls\CSC 1
Error (active) CS0006 Metadata file 'B:\Contents\Best Chat\Code\BestChat.Prefs.Data\bin\Debug\net8.0-windows\BestChat.Prefs.Data.dll' could not be found BestChat.Prefs.GUI.Ctrls B:\Contents\Best Chat\Code\BestChat.Prefs.GUI.Ctrls\CSC 1
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
CC#
Created by Will Pittenger on 8/18/2024 in #help
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
CC#
Created by Will Pittenger on 8/11/2024 in #help
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?
public abstract class T : System.Windows.Controls.UserControl
{
public abstract event System.Windows.RoutedEventHandler evtCanMoveOnChanged;
}
public class G : T
{
public override event System.Windows.RoutedEventHandler evtCanMoveOnChanged; // Warning here
}
public abstract class T : System.Windows.Controls.UserControl
{
public abstract event System.Windows.RoutedEventHandler evtCanMoveOnChanged;
}
public class G : T
{
public override event System.Windows.RoutedEventHandler evtCanMoveOnChanged; // Warning here
}
11 replies
CC#
Created by Will Pittenger on 11/9/2023 in #help
✅ 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
CC#
Created by Will Pittenger on 11/9/2023 in #help
❔ 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
CC#
Created by Will Pittenger on 11/8/2023 in #help
✅ How do you control which WPF property is the default for that class?
Examine the following XAML:
<SomeClass>
PropertyValue
</SomeClass>
<OtherClass>
<OtherClass.Property>
PropertyValue
</OtherClass.Property>
</OtherClass>
<SomeClass>
PropertyValue
</SomeClass>
<OtherClass>
<OtherClass.Property>
PropertyValue
</OtherClass.Property>
</OtherClass>
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
CC#
Created by Will Pittenger on 11/8/2023 in #help
❔ ✅ 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
CC#
Created by Will Pittenger on 11/6/2023 in #help
✅ 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.
<Base:AbstractVisualConversationTabCtrl
x:Class="BestChat.IRC.Global.View.ConversationViewCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.IRC.Global.View"
xmlns:Base="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
xmlns:OurDataCtxt="BestChat.Platform.Conversations;Assembly=BestChat.Platform.Conversations"
xmlns:DataDefs="clr-namespace:BestChat.IRC.Data.Defs;assembly=BestChat.IRC.Data"
xmlns:CalcBinding="clr-namespace:CalcBinding;assembly=CalcBinding"
xmlns:Emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:Ctrls="clr-namespace:BestChat.IRC.Global.View.Ctrls;assembly=BestChat.IRC.Global.View.Ctrls"
xmlns:GuiCtrls="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
d:DataContext="{x:Type d:DesignInstance Type=OurDataCtxt:AbstractConversation}"
mc:Ignorable="d">
<Base:AbstractVisualConversationTabCtrl
x:Class="BestChat.IRC.Global.View.ConversationViewCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.IRC.Global.View"
xmlns:Base="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
xmlns:OurDataCtxt="BestChat.Platform.Conversations;Assembly=BestChat.Platform.Conversations"
xmlns:DataDefs="clr-namespace:BestChat.IRC.Data.Defs;assembly=BestChat.IRC.Data"
xmlns:CalcBinding="clr-namespace:CalcBinding;assembly=CalcBinding"
xmlns:Emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
xmlns:Ctrls="clr-namespace:BestChat.IRC.Global.View.Ctrls;assembly=BestChat.IRC.Global.View.Ctrls"
xmlns:GuiCtrls="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
d:DataContext="{x:Type d:DesignInstance Type=OurDataCtxt:AbstractConversation}"
mc:Ignorable="d">
Then inside BestChat.Platform.Conversations.dll, we have BestChat.Platform.Conversations.AbstractConversation. Those appear to match to me.
namespace BestChat.Platform.Conversations
{
public abstract class AbstractConversation
.
.
.
}
namespace BestChat.Platform.Conversations
{
public abstract class AbstractConversation
.
.
.
}
34 replies
CC#
Created by Will Pittenger on 11/6/2023 in #help
✅ Null check not enough to safely convert from nullable enum
I have a class declaring an enum and a nullable value for that enum:
public readonly StdModeTypes? smt;
public readonly StdModeTypes? smt;
I then try to reference that field from a second class:
if(cmodeCur.smt != null)
mapModesWithStdTypes[cmodeCur.smt] = cmodeCur;
if(cmodeCur.smt != null)
mapModesWithStdTypes[cmodeCur.smt] = cmodeCur;
Yet even with the null check, the IDE is insisting that smt could be null and won't let me use the value:
Error CS1503 Argument 1: cannot convert from 'BestChat.IRC.Data.Defs.ChanMode.StdModeTypes?' to 'BestChat.IRC.Data.Defs.ChanMode.StdModeTypes'
Error CS1503 Argument 1: cannot convert from 'BestChat.IRC.Data.Defs.ChanMode.StdModeTypes?' to 'BestChat.IRC.Data.Defs.ChanMode.StdModeTypes'
What's going on?
28 replies
CC#
Created by Will Pittenger on 11/5/2023 in #help
✅ 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.
<Base:AbstractVisualConversationTabCtrl
x:Class="BestChat.IRC.Global.View.Ctrls.ConversationViewCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.IRC.Global.View.Ctrls"
xmlns:Base="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
xmlns:data="BestChat.Platform.Conversations;Assembly=BestChat.Platform.Conversations"
mc:Ignorable="d"
xmlns:CalcBinding="clr-namespace:CalcBinding;assembly=CalcBinding">
<Base:AbstractVisualConversationTabCtrl.Resources>
<Style
x:Key="ChkBoxStyle"
TargetType="CheckBox"
BasedOn="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}" />
</Base:AbstractVisualConversationTabCtrl.Resources>
<DockPanel>
<WrapPanel
x:Name="wrapDataBar"
DockPanel.Dock="Top" />
<Border
Background="Black" />
</DockPanel>
</Base:AbstractVisualConversationTabCtrl>
<Base:AbstractVisualConversationTabCtrl
x:Class="BestChat.IRC.Global.View.Ctrls.ConversationViewCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.IRC.Global.View.Ctrls"
xmlns:Base="clr-namespace:BestChat.GUI.Ctrls;assembly=BestChat.GUI.Ctrls"
xmlns:data="BestChat.Platform.Conversations;Assembly=BestChat.Platform.Conversations"
mc:Ignorable="d"
xmlns:CalcBinding="clr-namespace:CalcBinding;assembly=CalcBinding">
<Base:AbstractVisualConversationTabCtrl.Resources>
<Style
x:Key="ChkBoxStyle"
TargetType="CheckBox"
BasedOn="{StaticResource {x:Static ToolBar.ToggleButtonStyleKey}}" />
</Base:AbstractVisualConversationTabCtrl.Resources>
<DockPanel>
<WrapPanel
x:Name="wrapDataBar"
DockPanel.Dock="Top" />
<Border
Background="Black" />
</DockPanel>
</Base:AbstractVisualConversationTabCtrl>
9 replies
CC#
Created by Will Pittenger on 11/5/2023 in #help
✅ 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.
<Grid
x:Name="gridExtended"
DockPanel.Dock="Bottom"
IsMouseDirectlyOverChanged="OnExtendedToolBarMouseDirectlyOverChanged">
<Grid.RowDefinitions>
<RowDefinition
Height="10" />
<RowDefinition
Height="{Binding ExtendedToolBarRowTwoHeight, ElementName=window, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" />
</Grid.RowDefinitions>
<Separator
VerticalContentAlignment="Center"
HorizontalContentAlignment="Stretch"
Grid.ColumnSpan="25"
Height="1" />
<Grid
x:Name="gridExtended"
DockPanel.Dock="Bottom"
IsMouseDirectlyOverChanged="OnExtendedToolBarMouseDirectlyOverChanged">
<Grid.RowDefinitions>
<RowDefinition
Height="10" />
<RowDefinition
Height="{Binding ExtendedToolBarRowTwoHeight, ElementName=window, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" />
</Grid.RowDefinitions>
<Separator
VerticalContentAlignment="Center"
HorizontalContentAlignment="Stretch"
Grid.ColumnSpan="25"
Height="1" />
public System.Windows.GridLength ExtendedToolBarRowTwoHeight
{
get
{
if(gridExtended == null || chkExtendedToolBarShow == null)
System.Diagnostics.Debug.WriteLine("Nulls");
else
System.Diagnostics.Debug.WriteLine($"Extended: {gridExtended.IsMouseDirectlyOver
}\tCheckbox: {chkExtendedToolBarShow.IsChecked}");
return gridExtended != null && chkExtendedToolBarShow != null && (gridExtended.IsMouseDirectlyOver
|| chkExtendedToolBarShow.IsChecked == true) ? System.Windows.GridLength.Auto : new
(0);
}
}
public System.Windows.GridLength ExtendedToolBarRowTwoHeight
{
get
{
if(gridExtended == null || chkExtendedToolBarShow == null)
System.Diagnostics.Debug.WriteLine("Nulls");
else
System.Diagnostics.Debug.WriteLine($"Extended: {gridExtended.IsMouseDirectlyOver
}\tCheckbox: {chkExtendedToolBarShow.IsChecked}");
return gridExtended != null && chkExtendedToolBarShow != null && (gridExtended.IsMouseDirectlyOver
|| chkExtendedToolBarShow.IsChecked == true) ? System.Windows.GridLength.Auto : new
(0);
}
}
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
CC#
Created by Will Pittenger on 10/31/2023 in #help
✅ 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
CC#
Created by Will Pittenger on 10/19/2023 in #help
✅ 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?
<TreeView
x:Name="treeLogicalSelector">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate
DataType="TreeData:VisualTreeData"
ItemsSource="{Binding Children}">
<StackPanel
Orientation="Horizontal"
ToolTip="{Binding LocalizedLongDesc}">
<Emoji:TextBlock
Text="{Binding Icon}"
VerticalAlignment="Center" />
<Label
Content="{Binding LocalizedName}"
VerticalAlignment="Center" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<TreeView
x:Name="treeLogicalSelector">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate
DataType="TreeData:VisualTreeData"
ItemsSource="{Binding Children}">
<StackPanel
Orientation="Horizontal"
ToolTip="{Binding LocalizedLongDesc}">
<Emoji:TextBlock
Text="{Binding Icon}"
VerticalAlignment="Center" />
<Label
Content="{Binding LocalizedName}"
VerticalAlignment="Center" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
2 replies
CC#
Created by Will Pittenger on 10/17/2023 in #help
✅ 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
CC#
Created by Will Pittenger on 10/16/2023 in #help
✅ 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
CC#
Created by Will Pittenger on 10/12/2023 in #help
❔ 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.
Severity Code Description Project File Line Suppression State
Error XDG0031 Could not find the resource "BestChat.IRC.Data.Defs.NickServOpts.resources" among the resources "BestChat.IRC.Data.Defs.Resources.resources" embedded in the assembly "BestChat.IRC.Data", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkEditorDlg.xaml 211
Error XDG0031 Could not find the resource "BestChat.IRC.Data.Defs.ChanServOpts.resources" among the resources "BestChat.IRC.Data.Defs.Resources.resources" embedded in the assembly "BestChat.IRC.Data", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkEditorDlg.xaml 231
Severity Code Description Project File Line Suppression State
Error XDG0031 Could not find the resource "BestChat.IRC.Data.Defs.NickServOpts.resources" among the resources "BestChat.IRC.Data.Defs.Resources.resources" embedded in the assembly "BestChat.IRC.Data", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkEditorDlg.xaml 211
Error XDG0031 Could not find the resource "BestChat.IRC.Data.Defs.ChanServOpts.resources" among the resources "BestChat.IRC.Data.Defs.Resources.resources" embedded in the assembly "BestChat.IRC.Data", nor among the resources in any satellite assemblies for the specified culture. Perhaps the resources were embedded with an incorrect name. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkEditorDlg.xaml 231
2 replies
CC#
Created by Will Pittenger on 10/10/2023 in #help
✅ Can someone explain CA1416 about a call site only being reachable on ...
I'm getting the following warning that I don't understand.
Severity Code Description Project File Line Suppression State
Warning CA1416 This call site is reachable on all platforms. 'Network' is only supported on: 'Windows' 7.0 and later. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkListDlg.xaml.cs 89 Active
Severity Code Description Project File Line Suppression State
Warning CA1416 This call site is reachable on all platforms. 'Network' is only supported on: 'Windows' 7.0 and later. IRC.Global.View B:\Contents\Best Chat\Code\IRC\Global\View\NetworkListDlg.xaml.cs 89 Active
Both assemblies involved have the same .NET and Windows versions specified. I keep checking that.
114 replies
CC#
Created by Will Pittenger on 10/7/2023 in #help
✅ 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.
<Base:MyCtrlBase
x:Class="BestChat.Prefs.Ctrls.Global"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.Prefs.Ctrls"
xmlns:Base="clr-namespace:BestChat.Prefs.Data;assembly=BestChat.Prefs.Data"
mc:Ignorable="d">
<Grid></Grid>
<Base:MyCtrlBase
x:Class="BestChat.Prefs.Ctrls.Global"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:BestChat.Prefs.Ctrls"
xmlns:Base="clr-namespace:BestChat.Prefs.Data;assembly=BestChat.Prefs.Data"
mc:Ignorable="d">
<Grid></Grid>
Can someone tell me what I need to change?
2 replies