Reputation: 1441
So I have a class and I need to set a new instance of this class in XAML? Can someone has an idea for this?
Upvotes: 0
Views: 931
Reputation: 39966
First add this:
xmlns:yc="clr-namespace:WpfApplication1"
Then in the Window.Resources
you can a new instance of the class like this:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:yc="clr-namespace:WpfApplication1"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Window.Resources>
<yc:Class1 x:Key="myInstance" />
</Window.Resources>
<Grid>
....
</Grid>
Change the WpfApplication1
to the name of your project.
Upvotes: 3