✅ 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
.
.
.
}
14 Replies
JakenVeina
JakenVeina13mo ago
if you've tried it and it doesn't work, I'd have to say "yes, it matters"
Will Pittenger
Will PittengerOP13mo ago
In which case, the error should be the class was abstract.
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Will Pittenger
Will PittengerOP13mo ago
Please remember I don't need design time data. Just making sure the property names are valid.
JakenVeina
JakenVeina13mo ago
yeah, the syntax is fine I use it myself, regularly but yeah, doesn't work for abstract classes oh wait no @TeBeClone is right, the alternative syntax does work use {x:Type} to do the type lookup works fine
Will Pittenger
Will PittengerOP13mo ago
I tried that.
JakenVeina
JakenVeina13mo ago
then you're doing something else wrong even works with an abstract generic
d:DataContext="{d:DesignInstance Type={x:Type gamespace:GameBoardViewModelBase`1}}"
d:DataContext="{d:DesignInstance Type={x:Type gamespace:GameBoardViewModelBase`1}}"
I now get intellisense on all the other bindings
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Will Pittenger
Will PittengerOP13mo ago
Except I tried d:DataContext="{d:DesignInstance Type={x:Type OurDataCtxt:AbstractConversation}}" too.
JakenVeina
JakenVeina13mo ago
¯\_(ツ)_/¯ wOrKs On My MaChInE
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Will Pittenger
Will PittengerOP13mo ago
.NET 7.0 in VS 2022?
JakenVeina
JakenVeina13mo ago
this one's actually net6.0-windows but it shouldn't matter so long as it's .NET 5+ or was it 6 when WPF was added?
Will Pittenger
Will PittengerOP13mo ago
Well, I took the DesignInstance stuff out for now. I'm back to trying to resolve https://discord.com/channels/143867839282020352/1170760309410107473.
Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
Want results from more Discord servers?
Add your server