I would like to set properties in XAML from my C# code. The way I do it, it totally doesn't work.
XAML
<Page
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="x:bind width_background" Height="x:bind height_background">
<Grid>
<TextBox x:Name="Textbox1" Text="x:bind text_textbox1" />
<Border BorderThickness="1" Height="x:bind height_border" Width="x:bind width_border"/>
</Grid>
</Page>
Code Behind
namespace Test
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
int height_background = 500;
int width_background = 600;
int height_border = 500;
int width_border = 600;
string text_textbox1 = "string test"
}
}
}
The first you should define the property. The second is you should put the bind express in
{and please see the code.You can find all the code in github
More about bind, please see Data binding overview - UWP applications