简体   繁体   中英

Accessing XAML controls in WPF

I'm using this code in .xaml, as I created a user defined control( TextBox ) NumericTextbox :

<local:NumericTextBox Grid.Column="1"
       local:NumericTextBox.Mask="Decimal"
       local:NumericTextBox.MaximumValue="55"
       local:NumericTextBox.MinimumValue="0"
       Name="abc"
       Grid.Row="0"
       Text="{Binding Path=IPAddressProperty}" />

I want to access that NumericTextbox in .xaml.cs and I have to give that minimum and maximum value also in .xaml.cs file,

Can anyone help me out please?

This question would be much more readable if you put your XAML up in the original post.

You need to give it a name in XAML:

<local:NumericTextBox x:Name="MyTextBox" />

Then you can reference its properties with that name in C# code-behind:

this.MyTextBox.MinimumValue = 0;
this.MyTextBox.MaximumValue = 255;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM