User control binding and usage
Posted: 28 Jun 2024, 20:46
Hi. I have an user control
It has ItemText.
So, now I want to use the control somewhere:
How the properties should be defined in the control to work properly? I tried some, but always has "the property was not found in type".
Code: Select all
<UserControl x:Class="HUD.UserStateIcon"
...
xmlns:local="clr-namespace:HUD"
d:DesignHeight="50" d:DesignWidth="50" RenderTransformOrigin="0.5,0.5">
...
<Grid x:Name="Root" RenderTransformOrigin="0.5,0.5">
<Label x:Name="Text" Content="{Binding ItemText}" Grid.Row="1"/>
</Grid>
</UserControl>So, now I want to use the control somewhere:
Code: Select all
<Window x:Class="HUD.MainWindow"
...
<Grid>
<local:UserStateIcon Grid.Column="1" ItemText="Hello world"/>
</Grid>