Showing posts with label silverlight. Show all posts
Showing posts with label silverlight. Show all posts

Thursday, December 31, 2009

How To Add Border To Image Within DataGrid Column in Silverlight


<data:DataGridTemplateColumn Header="Image">
                        <data:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Border BorderBrush="Black" Width="101"  BorderThickness="1,1,1,1" Height="13" >
                                    <Image Width="25" Height="11" Source="http://localhost/SLR/images/pers_org.png" Stretch="UniformToFill" HorizontalAlignment="Left"  Canvas.Top="0" Canvas.Left="0" >
                                    </Image>
                                </Border>
                            </DataTemplate>
                        </data:DataGridTemplateColumn.CellTemplate>
                    </data:DataGridTemplateColumn>

//Bind the Following code within datagrid LoadingRow Event

Border border = (Border)dgName.Columns[4].GetCellContent(e.Row);// value 4 is the Possible of the Cell in the datagrid
Image image = (Image)border.Child;
//RelMang tmpRm = (RelMang)e.Row.DataContext;
//image.Width = Convert.ToDouble(tmpRm.mx_Rel_Prcntg.ToString());
image.Width = Convert.ToDouble(20); // Dynamically Setting Width of the Image Which in Datagrid Cell

Thursday, December 24, 2009

Silverlight How To Pass Values Between Pages or Forms

In App.xaml.cs have declared some application level variables as follows,

private string valueToPass

public string valTo
{
    get
    {
        return valueToPass;
    }
    
    set
    {
        valueToPass = value;
    }
}

page1.xaml.cs

App ap = (App)Application.Current;
ap.valueToPass = "YourValue";


page2.xaml.cs

App ap = (App)Application.Current;
messageBox.show(ap.valueToPass);

How To wrap Text In silverlight DataGrid Column

Make your datagrid AutoGenerateColumns="False" , then do the following changes to wrap text in the datagrid coloumn

<data:DataGridTemplateColumn Header="Your Header" Width="150">
         <data:DataGridTemplateColumn.CellTemplate>
                 <DataTemplate>
                        <TextBlock TextWrapping="Wrap" Text="{Binding Your_Data_Display}" />
                 </DataTemplate>
        </data:DataGridTemplateColumn.CellTemplate>
</data:DataGridTemplateColumn>

Wednesday, December 23, 2009

Silverlight The type or namespace name 'IValueConverter' could no


While Using Silverlight if you are getting the following Error "The type or namespace name 'IValueConverter' could not be found (are you missing a using directive or an assembly reference?)" Just Include namespace System.Windows.Data; in your code behind.

Silverlight The type or namespace name 'BitmapImage' could not be


While Using Silverlight if you are getting the following Error "The type or namespace name 'BitmapImage' could not be found (are you missing a using directive or an assembly

reference?)
" Just Include namespace System.Windows.Media.Imaging; in your application

Monday, December 7, 2009

How To Pass values from iframe to Controls In parent Document


if(parent.document.Yourformname.YOurfieldname != null){

    parent.document.Yourformname.YourfieldId.value = SetYourValue;
}

For Div Content

if(parent.document.all["DIVName"] != null){

    parent.document.all["YourDIVName"].innerHTML =  SetYourValue;
}

Wednesday, September 16, 2009

How To Set Background Image For Canvas


<Canvas.Background>
            <ImageBrush  ImageSource="images/dashboard.jpg" Stretch="Fill"  />
</Canvas.Background>


See Also...
ImageBrush
Strech Property


Thursday, September 10, 2009

Tuesday, September 1, 2009

The type or namespace name 'AspNetCompatibilityRequirements' coul

If Getting The type or namespace name 'AspNetCompatibilityRequirements' could not be found, then have to include the following namespace in class,

Using System.ServiceModel.Activation // C#
Imports System.ServiceModel.Activation // VB

Friday, August 21, 2009

Silverlight : How To Bring Control To Front

Canvas.SetZIndex(Your_Element_Name,Value_To_Bring_It_To_Front);

Wednesday, August 12, 2009

How To Detect Silverlight Installed In Client Machine

<html>
    <body>
        <script language="javascript">
        var browser = navigator.appName;
        var SLInstalled = false;
        if (browser == 'Microsoft Internet Explorer')
        {
            try
            {
                var slControl = new ActiveXObject('AgControl.AgControl');//IE
                SLInstalled = true;
            }
            catch (e)
            {
                SLInstalled = false;
            }
        }
        else
        {   
            try
            {
                if (navigator.plugins["Silverlight Plug-In"]) // Other Than IE
                {
                    SLInstalled = true;
                }
            }
            catch (e)
            {
                SLInstalled = false;
            }
        }
            if(SLInstalled == true)
            {
                    alert('Silverlight Installed');
            }
            else
            {
                  alert('Silverlight Not Installed');
             }
        </script>
    </body>
</html>


Tuesday, August 11, 2009

How To Reset DoubleAnimationUsingKeyFrames

YourDoubleAnimationUsingKeyFramesName.KeyFrames.Clear();

How To Triggers Event In Silverlight

// Inlcude These two namespaces for the Automation Process
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;


ButtonAutomationPeer buttonAutoPeer = new ButtonAutomationPeer(YourButtonName);
IInvokeProvider invokeProvider = buttonAutoPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
invokeProvider.Invoke();


Monday, August 10, 2009

How To Get Storyboard Current Status

Syntax
          StoryboardName.GetCurrentState

GetCurrentState Method enumeration values are
          Active    -  The current animation changes in direct relation to that of its parent.
          Filling    -  The animation continues and does not change in relation to that of its parent.
          Stopped  -  The animation is stopped.


Monday, August 3, 2009

Silverlight Alert Box

System.Windows.Browser.HtmlPage.Window.Invoke("Alert", "Testing");

How To Hide Legend In PieChar Silverlight

<UserControl x:Class="Charting.Pagee"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows"
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">

        <charting:Chart Title="Legend Disabled">         

            <charting:Chart.LegendStyle>
                
                <Style TargetType="datavis:Legend">
                    
                    <Setter Property="Width" Value="0"/>
                    <Setter Property="Height" Value="0"/>
                    
                </Style>
                
            </charting:Chart.LegendStyle>
            
            <charting:Chart.Series>
                
                <charting:PieSeries  DependentValuePath="X" >                    
                    <charting:PieSeries.ItemsSource>
                        <PointCollection>
                            <Point X="1"/>
                            <Point X="2"/>
                            <Point X="3"/>
                            <Point X="4"/>
                        </PointCollection>
                    </charting:PieSeries.ItemsSource>
                </charting:PieSeries>
                
            </charting:Chart.Series>
            
        </charting:Chart>
    </Grid>
</UserControl>



Friday, July 31, 2009

Silverlignt How To Get The Cell Content Of The DataGrid When AutoGenerateColumns Set True

private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
           TextBlock tb = dg.Columns[0].GetCellContent(e.AddedItems[0]) as TextBlock;
           //tb.text will hold the Column Content
}


Wednesday, July 29, 2009

Getting AG_E_PARSER_BAD_PROPERTY_VALUE Error

Reason For Getting This Error "AG_E_PARSER_BAD_PROPERTY_VALUE"

I) Haven't defined the event handler in code behind, but have assigned it in xaml
II) not setting the correct event args type on the handler

How To Change the start page Silverlight XAML

Go to app.xaml.cs, find Application_Startup, set your xaml page which you want to run during startup.

app.xaml.cs
private void Application_Startup(object sender, StartupEventArgs e)
{
// this.RootVisual = new Page(); // Default
this.RootVisual = new UserDefinedXaml(); // Changed Xaml, if u add UserDefinedXaml.xaml to your project.
}


app.xaml.vb
Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
Me.RootVisual = New UserDefinedXaml()
End Sub

Friday, May 15, 2009

Silverlight How to Convert String to Thickness

Thickness res = new Thickness();
res = new Thickness(Convert.ToDouble(e.GetPosition(null).Y.ToString()));

By Default e.GetPosition(null).Y is Double datatype for example i convert that into string and again convert that to Double