Quest for a Range control

For nearly two weeks I was on a quest to find a Range control, ie a slider with two thumbs. After going several rounds through all the resources available online and offline I figured, there isn’t a ‘free’ range control.

And I really was in need of one. Found Jerry Nixon’s answer to someone’s post on StackOverFlow which served me as a base for the control. I have no clue how to make a custom control. So have uploaded the whole project to GitHub. Feel free to contribute or file issues.

Here’s your range control! 🙂

https://github.com/alfah-plackal/CustomSlider

May the code be with you! 😀

Advertisements

Quick Tip #4 – Creating Row and Column Definitions through code

Xaml is a piece of cake for Grid related adjustments. But a little work needs to be done if yyou are trying to achieve the same through the code-behind.

 
</pre>
<pre>Grid parentGrid = new Grid();
RowDefinition rd = new RowDefinition();
RowDefinition rd2 = new RowDefinition();</pre>
<pre>ColumnDefinition col1 = new ColumnDefinition();
ColumnDefinition col2 = new ColumnDefinition();
ColumnDefinition col3 = new ColumnDefinition();

col1.Width = new GridLength(1, GridUnitType.Auto);
col2.Width = new GridLength(1, GridUnitType.Star);
col3.Width = new GridLength(1, GridUnitType.Auto);

parentGrid.ColumnDefinitions.Add(col1);
parentGrid.ColumnDefinitions.Add(col2);
parentGrid.ColumnDefinitions.Add(col3);

parentGrid.RowDefinitions.Add(rd);
parentGrid.RowDefinitions.Add(rd2);

Grid.SetColumn(dotBorder, 0); // Setting a Border element to (0,0)
Grid.SetRow(dotBorder, 0);

Grid.SetColumn(dateText, 1); // Setting a textblock element to (0,1)
Grid.SetRow(dateText, 0);

Grid.SetColumn(delButton, 2); // Setting a button to (0,2)
Grid.SetRow(delButton, 0);

Grid.SetColumn(SympStack, 0);// Setting a Stack panel to row 0 and columnspan of 3
Grid.SetColumnSpan(SympStack, 3);
Grid.SetRow(SympStack, 1);

parentGrid.Children.Add(dotBorder); // Adding all the elements to the grid
parentGrid.Children.Add(dateText);
parentGrid.Children.Add(delButton);

parentGrid.Children.Add(SympStack);

May the code be with you! 😀
logosmall