Facebook Twitter Gplus LinkedIn YouTube Google Maps RSS
Home Posts tagged "silverlight" (Page 2)
formats

Silverlight Numeric TextBox

Published on June 30, 2010 by in Technical

Just copy paste the following code in your helper class/ project.

This number text box can handle whole numbers and decimal numbers.

using System.Windows.Controls;
using System.Windows.Input;
using System.Text.RegularExpressions;

namespace Ravi.UI.Silverlight
{
///

/// Custom TextBox for handling numbers/decimals
///

public class NumericTextBox : TextBox
{
#region Properties

///

/// Number of decimal places
///

public int DecimalPlaces { get; set; }

///

/// Returns true if the control allows decimals
///

public bool AllowDecimal { get; set; }

#endregion

#region Methods

///

/// Returns true if there is a decimal
///

///
private bool HasDecimal()
{
return this.Text.Contains(“.”);
}

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Silverlight TextBlock with BackColor

Published on June 30, 2010 by in Technical

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Ravi.UI.Silverlight
{
///

/// This control is a TextBox pretending to be a TextBlock.
/// Reason For Creation: BackColor cannot be set on TextBlock and TexBlock is a sealed control.
///

public class TextBlock : System.Windows.Controls.TextBox
{
private Border MouseOverBorder;
private Border ReadOnlyBorder;

public override void OnApplyTemplate()
{
base.OnApplyTemplate();

#region Variables

var zeroThickNess = new Thickness(0);
var transparent = new SolidColorBrush(Colors.Transparent);
var contentElement = GetTemplateChild(“ContentElement”) as ScrollViewer;

#endregion

#region Setting the Properties

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

IValueConverter: Bool to Visibility

Published on June 30, 2010 by in Technical

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Ravi.Infrastructure.Converters
{
///
/// A type converter for visibility and boolean values.
///
public class ConvertBoolToVisibility : IValueConverter
{
public object Convert(
object value,
Type targetType,
object parameter,
CultureInfo culture)
{
bool visibility = (bool)value;
return visibility ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(
object value,
Type targetType,
object parameter,
CultureInfo culture)
{
Visibility visibility = (Visibility)value;
return (visibility == Visibility.Visible);
}
}
}

 
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

Column Sort in DataGridTemplateColumn

Published on April 9, 2010 by in Technical

In your DataGridTemplateColumn you have SortMemberPath set to “”. If you set this to an actual property on the item (say, CompleteDate), you should be able to sort. You can also set CanUserSort=”true” or CanUserSort=”false” on selected columns.

SortMemberPath gives the property to sort on when the user attempts a sort. If this isn’t set, then the grid doesn’t know how to sort that column ( it does not use the text in the column)
Ex:

 
Tags:
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
formats

DataContext and ItemsList

<ListBox x:Name=”lstbxTest” Width=”100″ Height=”100″ Margin=”239,407,301,0″ VerticalAlignment=”Top” ItemsSource=”{Binding}” d:LayoutOverrides=”Height”>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation=”Vertical”>
<TextBox Text=”{Binding EmpId}” VerticalAlignment=”Top” HorizontalAlignment=”Left”/>

</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>

</ListBox>
<data:DataGrid x:Name=”DGTest” Height=”89″ HorizontalAlignment=”Left” Margin=”137,342,0,0″ VerticalAlignment=”Top” Width=”90″/>


CS File:
this.DataContext = EList;
DGTest.ItemsSource = EList;
btnTest.Click += new RoutedEventHandler(btn_Click);

http://codebetter.com/blogs/karlseguin/archive/2008/11/27/back-to-basics-delegates-anonymous-methods-and-lambda-expressions.aspx

 
Tags:
 Share on Facebook Share on Twitter Share on Reddit Share on LinkedIn
No Comments  comments 
© All rights reserved to Cyberbrutus. 2012
credit

Switch to our mobile site