Hi,
By default Silverlight will not download an image more than once if is contained within the image cache. That is, as long as the URI remains the same it will reference the image from the cache.
So what if the image changed on the server even though it has the same URI? Your application can force an update by setting the property IgnoreImageCache to true.
Example:
Image img = new Image();
Uri uri = new Uri("http://YourServer.com/MyImage.png", UriKind.Absolute);
BitmapImage bi = new System.Windows.Media.Imaging.BitmapImage(uri);
bi.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
img.Source = bi;
LayoutRoot.Children.Add(img);
Wednesday, April 21, 2010
Monday, November 30, 2009
Paging in wrapPanel
Here is the paging Functionality in Wrap Panel
I have added Wrap panel using the namespace system.windows.Controls.toolkit as shown in the image

Do not set width on wrap panel. Wrap panel loads image based on main page size changes
I have loaded images from xml and when the main window is resized paging changes based on that
public MainPage()
{
InitializeComponent();
this.SizeChanged += new SizeChangedEventHandler(MainPage_SizeChanged);
webClient = new WebClient();
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
webClient.OpenReadAsync(new Uri("Application.xml", UriKind.RelativeOrAbsolute));
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
Paging();
}
private void Paging()
{
appHeight = this.ActualHeight;
appWidth = this.ActualWidth;
pageSize = Convert.ToInt32(Math.Floor(((this.ActualHeight) - 216) / 38));
if (pageSize != 0.0)
{
pagecount = Convert.ToInt32(Math.Ceiling(totalSize / pageSize));
PageStackPanel.Children.Clear();
myWrapPanel.Children.Clear();
if (pagecount != 1)
{
for (int i = 0; i <= pagecount; i++) {
HyperlinkButton href = new HyperlinkButton();
href.Content = i + 1;
href.Click += new RoutedEventHandler(href_Click);
PageStackPanel.Children.Add(href);
}
}
}
GetInteractivity(1);
}
void href_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton hf = sender as HyperlinkButton; GetInteractivity(Convert.ToInt32(hf.Content));
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
try
{
xmlParser = new XMLParser(e.Result);
BindXML(); webClient.OpenReadCompleted -= new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
totalSize = interactivityList.Count; Paging();
GetInteractivity(1);
}
catch (Exception ex) { }
}
private void GetInteractivity(double pgSize)
{
myWrapPanel.Children.Clear();
int startVal = Convert.ToInt32((pgSize - 1) * pageSize);
int endVal = Convert.ToInt32((pgSize) * pageSize);
endVal = endVal > Convert.ToInt32(totalSize) ? Convert.ToInt32(totalSize) : endVal;
for (int i = startVal; i <=endVal;i++)
{
Image img = new Image();
img.Width = 160;
img.Height = 160;
string imgpath = interactivityList[i].imagePath.ToString();
Uri uri = new Uri(imgpath, UriKind.Relative);
ImageSource src = new BitmapImage(uri);
img.Source = src;
img.Tag = interactivityList[i].xapfilePath;
img.MouseLeftButtonDown += new MouseButtonEventHandler(image1_MouseLeftButtonDown);
Rectangle rect = new Rectangle();
rect.Width = 100;
rect.Height = 100;
myWrapPanel.Children.Add(img);
myWrapPanel.Children.Add(rect);
}
}
private void BindXML()
{
List elements = xmlParser.GetElements("Application");
if (elements.Count > 0)
{
for (int i = 0; i <= elements.Count; i++)
{
Interactivity interactivity = new Interactivity();
imageElement = elements[i].Element("ImagePath");
interactivity.imagePath = imageElement.Value.ToString();
xapElement = elements[i].Element("xapFilePath");
interactivity.xapfilePath = xapElement.Value.ToString();
interactivityList.Add(interactivity);
}
}
} public class Interactivity
{
public string imagePath { get; set; }
public string xapfilePath { get; set; }
}
NOTE:
Replace <= with <
I have added Wrap panel using the namespace system.windows.Controls.toolkit as shown in the image

Do not set width on wrap panel. Wrap panel loads image based on main page size changes
I have loaded images from xml and when the main window is resized paging changes based on that
public MainPage()
{
InitializeComponent();
this.SizeChanged += new SizeChangedEventHandler(MainPage_SizeChanged);
webClient = new WebClient();
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
webClient.OpenReadAsync(new Uri("Application.xml", UriKind.RelativeOrAbsolute));
this.Loaded += new RoutedEventHandler(MainPage_Loaded);
}
void MainPage_SizeChanged(object sender, SizeChangedEventArgs e)
{
Paging();
}
private void Paging()
{
appHeight = this.ActualHeight;
appWidth = this.ActualWidth;
pageSize = Convert.ToInt32(Math.Floor(((this.ActualHeight) - 216) / 38));
if (pageSize != 0.0)
{
pagecount = Convert.ToInt32(Math.Ceiling(totalSize / pageSize));
PageStackPanel.Children.Clear();
myWrapPanel.Children.Clear();
if (pagecount != 1)
{
for (int i = 0; i <= pagecount; i++) {
HyperlinkButton href = new HyperlinkButton();
href.Content = i + 1;
href.Click += new RoutedEventHandler(href_Click);
PageStackPanel.Children.Add(href);
}
}
}
GetInteractivity(1);
}
void href_Click(object sender, RoutedEventArgs e)
{
HyperlinkButton hf = sender as HyperlinkButton; GetInteractivity(Convert.ToInt32(hf.Content));
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
try
{
xmlParser = new XMLParser(e.Result);
BindXML(); webClient.OpenReadCompleted -= new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
totalSize = interactivityList.Count; Paging();
GetInteractivity(1);
}
catch (Exception ex) { }
}
private void GetInteractivity(double pgSize)
{
myWrapPanel.Children.Clear();
int startVal = Convert.ToInt32((pgSize - 1) * pageSize);
int endVal = Convert.ToInt32((pgSize) * pageSize);
endVal = endVal > Convert.ToInt32(totalSize) ? Convert.ToInt32(totalSize) : endVal;
for (int i = startVal; i <=endVal;i++)
{
Image img = new Image();
img.Width = 160;
img.Height = 160;
string imgpath = interactivityList[i].imagePath.ToString();
Uri uri = new Uri(imgpath, UriKind.Relative);
ImageSource src = new BitmapImage(uri);
img.Source = src;
img.Tag = interactivityList[i].xapfilePath;
img.MouseLeftButtonDown += new MouseButtonEventHandler(image1_MouseLeftButtonDown);
Rectangle rect = new Rectangle();
rect.Width = 100;
rect.Height = 100;
myWrapPanel.Children.Add(img);
myWrapPanel.Children.Add(rect);
}
}
private void BindXML()
{
List
if (elements.Count > 0)
{
for (int i = 0; i <= elements.Count; i++)
{
Interactivity interactivity = new Interactivity();
imageElement = elements[i].Element("ImagePath");
interactivity.imagePath = imageElement.Value.ToString();
xapElement = elements[i].Element("xapFilePath");
interactivity.xapfilePath = xapElement.Value.ToString();
interactivityList.Add(interactivity);
}
}
} public class Interactivity
{
public string imagePath { get; set; }
public string xapfilePath { get; set; }
}
NOTE:
Replace <= with <
LoadXap File Dynamically through HTML page
How to load xap file dynamically in silverlight?

We can use xap loader class method or else u can load xap file via html Page.Here is my example to load the xap file dynamically
Lets Create a sample application and bind the image in tat application .I have created the project in the name of sampleapplication .

Now i have created the other project name loadXAP to load sampleapplication XAP file.I have added MyPage.htm Page in the web project,and add the following code as in the image
and add div with the Id 'silverlightControlHost' in the body tag .Now place the sample application Xap file in the ClientBin folder of loadXap Application.Now i have place thumbnail of image and when i click on the image it redirects to MyPage.htm file with the XAP filename as Query string .Here is the screen shot of the application


Thursday, October 22, 2009
Accordian Control Problem in Blend
Hi ,
When the Accordian Control is added in silverlight. When you open in Blend You could not able to find the control in Expression Blend.
To View in the Blend You should add reference System.Windows.Controls.Layout.Toolkit. and System.Windows.Controls.Toolkit
When the Accordian Control is added in silverlight. When you open in Blend You could not able to find the control in Expression Blend.
To View in the Blend You should add reference System.Windows.Controls.Layout.Toolkit. and System.Windows.Controls.Toolkit
Wednesday, October 14, 2009
ErrorCode:4001 ErrorType:MediaError AG_E_NETWORK_ERROR
Hi all,
ErrorCode:4001 ErrorType:MediaError AG_E_NETWORK_ERROR
I get the above error when i play a media file. It ruins my whole day.
At last i found by adding the media file in the Bin Debug/Release folder and in the web i have added in the client bin folder. It solve my issue
ErrorCode:4001 ErrorType:MediaError AG_E_NETWORK_ERROR
I get the above error when i play a media file. It ruins my whole day.
At last i found by adding the media file in the Bin Debug/Release folder and in the web i have added in the client bin folder. It solve my issue
Wednesday, September 2, 2009
Search Query in sql
Hi ,I have the table name stipr and category with the following fields as follows
iprdate
iprno
deliveredto
classification
requiredfor
stcategoryID
mainstatus
and category table with the field of
stcategoryID
Now my requirement is i have to write the query with the different combination as followsfor ex:
declare @IPRdate datetime,@IPRNo nvarchar(50),@DeliveredTo nvarchar(50),@Classification nvarchar(50),@RequiredFor nvarchar(50),@STCategoryID nvarchar(50),@MainStatus nvarchar(50)
Begin
if @IPRdate !=null and @IPRNo=null and @DeliveredTo = null AND @Classification = null AND @RequiredFor = null AND @STCategoryID = null AND @MainStatus = nullBeginselect * from Store.STIPR,Store.STCategory where IPRdate=@IPRdateEndelse if @IPRdate !=null and @IPRNo !=null and @DeliveredTo = null AND @Classification = null AND @RequiredFor = null AND @STCategoryID = null AND @MainStatus = null
Begin
select * from Store.STIPR,Store.STCategory where IPRdate=@IPRdate and IPRNo=@IPRNo
End
End
After a long search i found the query using case then
select * from Store.STIPR,Store.STCategory where
iprdate = (case when @IPRdate is null then iprdate else @IPRdate end) and
iprno = (case when @IPRNo is null then iprno else @IPRNo end) and
deliveredto = (case when @DeliveredTo is null then deliveredto else @DeliveredTo end) and
classification = (case when @Classification is null then classification else @Classification end) and
requiredfor = (case when @RequiredFor is null then requiredfor else @RequiredFor end) and
stcategoryID = (case when @STCategoryID is null then stcategoryID else @STCategoryID end) and
mainstatus = (case when @MainStatus is null then mainstatus else @MainStatus end)
iprdate
iprno
deliveredto
classification
requiredfor
stcategoryID
mainstatus
and category table with the field of
stcategoryID
Now my requirement is i have to write the query with the different combination as followsfor ex:
declare @IPRdate datetime,@IPRNo nvarchar(50),@DeliveredTo nvarchar(50),@Classification nvarchar(50),@RequiredFor nvarchar(50),@STCategoryID nvarchar(50),@MainStatus nvarchar(50)
Begin
if @IPRdate !=null and @IPRNo=null and @DeliveredTo = null AND @Classification = null AND @RequiredFor = null AND @STCategoryID = null AND @MainStatus = nullBeginselect * from Store.STIPR,Store.STCategory where IPRdate=@IPRdateEndelse if @IPRdate !=null and @IPRNo !=null and @DeliveredTo = null AND @Classification = null AND @RequiredFor = null AND @STCategoryID = null AND @MainStatus = null
Begin
select * from Store.STIPR,Store.STCategory where IPRdate=@IPRdate and IPRNo=@IPRNo
End
End
After a long search i found the query using case then
select * from Store.STIPR,Store.STCategory where
iprdate = (case when @IPRdate is null then iprdate else @IPRdate end) and
iprno = (case when @IPRNo is null then iprno else @IPRNo end) and
deliveredto = (case when @DeliveredTo is null then deliveredto else @DeliveredTo end) and
classification = (case when @Classification is null then classification else @Classification end) and
requiredfor = (case when @RequiredFor is null then requiredfor else @RequiredFor end) and
stcategoryID = (case when @STCategoryID is null then stcategoryID else @STCategoryID end) and
mainstatus = (case when @MainStatus is null then mainstatus else @MainStatus end)
Friday, July 31, 2009
SilverLight Interview Questions
What are the types of containers in silver light?
dock panel-dock panel is used to arrange a set of objects around the edges of panel. Dock Panel’s Dock property enables you to specify the location of objects inside Dock Panel. If you set the LastChild Fill property to true (the default value) and the last element is allowed to resize, the last element added to the panel will resize to fill the remaining space. If the last element is set to a specific size, the last element will be set to the specified size and positioned in the middle of the remaining space. The order in which elements are added to the dock panel is important.
Wrap Panel-Wrap panel is used to wrap the content in the next line.
What is silverlight .js file?
silverlight.js is a helper file is used when adding a silverlight application to a web page via javascript .It contains more helper method like get silverlight,ongetsilverlight,etc.We can add silverlight application to a web page by an alternate way asusing objecttag in html element
Does Silverlight support ADO.NET? and How to load the data to Silverlight from database?
It Does not support ado.net .have to use via WCF service,
How to use the styles in Silverlight? Can we load the external CSS file into Silverlight?
NO, it is not possibel to load external css in silverlight.We can use setter property to in app.xaml to apply the style.
For ex:
In app.xaml
style x:Key="titleBorder" TargetType="Border"
setter property="Background" value="#ff0000"
Style
if we r using brush then use Setter.value under setter.property
To use in the page
border style="{staticresource TitleBorder}>
textBlock text="GetData" style="{staticresource titleborder}"
border
can we use more than one xaml file in same project? explain?
yes we can use.To redirect from one xaml to other xaml
App app = (App)Application.Current;
app.UserName = txtUser.Text;
App.GoToPage(new Page2());
public static void GoToPage(UserControl nextPg)
{
App app = (App)Application.Current;
// Remove the displayed page
app.mainUI.Children.Clear();
// Show the next page
app.mainUI.Children.Add(nextPg);
}
to pass the parameter u can created property class and assign the value before passing parameter
dock panel-dock panel is used to arrange a set of objects around the edges of panel. Dock Panel’s Dock property enables you to specify the location of objects inside Dock Panel. If you set the LastChild Fill property to true (the default value) and the last element is allowed to resize, the last element added to the panel will resize to fill the remaining space. If the last element is set to a specific size, the last element will be set to the specified size and positioned in the middle of the remaining space. The order in which elements are added to the dock panel is important.
Wrap Panel-Wrap panel is used to wrap the content in the next line.
What is silverlight .js file?
silverlight.js is a helper file is used when adding a silverlight application to a web page via javascript .It contains more helper method like get silverlight,ongetsilverlight,etc.We can add silverlight application to a web page by an alternate way asusing objecttag in html element
Does Silverlight support ADO.NET? and How to load the data to Silverlight from database?
It Does not support ado.net .have to use via WCF service,
How to use the styles in Silverlight? Can we load the external CSS file into Silverlight?
NO, it is not possibel to load external css in silverlight.We can use setter property to in app.xaml to apply the style.
For ex:
In app.xaml
style x:Key="titleBorder" TargetType="Border"
setter property="Background" value="#ff0000"
Style
if we r using brush then use Setter.value under setter.property
To use in the page
textBlock text="GetData" style="{staticresource titleborder}"
border
can we use more than one xaml file in same project? explain?
yes we can use.To redirect from one xaml to other xaml
App app = (App)Application.Current;
app.UserName = txtUser.Text;
App.GoToPage(new Page2());
public static void GoToPage(UserControl nextPg)
{
App app = (App)Application.Current;
// Remove the displayed page
app.mainUI.Children.Clear();
// Show the next page
app.mainUI.Children.Add(nextPg);
}
to pass the parameter u can created property class and assign the value before passing parameter
Subscribe to:
Posts (Atom)
