I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Its a very simple method to bind Text Box from slider control in the windows phone. You can use Property="{Binding <source property>, ElementName=<Source Name>}" this method. Lets take an simple example
1. Add one Silder and One Text Box control on windows phone phone.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox x:Name="txtbox1" HorizontalAlignment="Left" Height="72" Margin="33,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="335" AcceptsReturn="True" Text="{Binding Value,ElementName=slider1}"></TextBox>
<Slider x:Name="slider1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="446" Margin="0,39,0,0" ValueChanged="slider1_ValueChanged"/>
</Grid>
1. Add one Silder and One Text Box control on windows phone phone.
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBox x:Name="txtbox1" HorizontalAlignment="Left" Height="72" Margin="33,139,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="335" AcceptsReturn="True" Text="{Binding Value,ElementName=slider1}"></TextBox>
<Slider x:Name="slider1" HorizontalAlignment="Left" VerticalAlignment="Top" Width="446" Margin="0,39,0,0" ValueChanged="slider1_ValueChanged"/>
</Grid>
Code Generate the following output
If you want to show only integer number into text box then use Round( ) method of Meth class in ValueChanged event. Add this in .xaml.cs file
private void slider1_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
slider1.Value = Math.Round(e.NewValue);
}
Comments
Post a Comment