Thursday, August 30, 2012

Popup to be shown Every 5 minutes

Popup to be shown Every 5 minutes

Hi

 

I have a child windows which needs to be shown every 5 minutes

How can i achieve this task. Should i use Threading ? Pls note I dont want to use Notification Window as the requirement is to be displayed in a Childwindow

 

Answers & Comments...

Answer: 1

GaneshGdrBlr

I have a child windows which needs to be shown every 5 minutes

Make use of DispatcherTimer, in tick event open the childwindow and close it in close event.

http://amjadsilverlight.wordpress.com/2011/09/27/how-to-use-dispatchertimer-in-silverlight/

http://www.java2s.com/Code/Silverlight/Data/EventDispatcherTimer.htm

http://msdn.microsoft.com/en-us/library/cc189084(v=vs.95).aspx





receiving diffent list from domain

receiving diffent list from domain

ı have a business  project . ı use entity framework. ı have a method in domainservice which receive company names

when ı was load information with loadoperation<tEntity>

for example ı have two rows informaiton in domain   method .rows diffent,but in to code side entity have two rows but rows are same

ı cant find why??

code side-----

ctx.Load(ctx.GetifrmgridQuery(prno)).Completed += (re, fg) =>

{
List<ihtiyacfirmaPOCO> lfirma = new List<ihtiyacfirmaPOCO>();

LoadOperation<ifrmPOCO> rslt = re as LoadOperation<ifrmPOCO>;

ihtiyacfirmagrid.ItemsSource = rslt.Entities.ToList();

var itm = ihtiyacfirmagrid.ItemsSource;

ihtiyacfirmagrid.ItemsSource =null;

ihtiyacfirmagrid.ItemsSource = itm;

};

domain side---

[Query]
public IQueryable<ifrmPOCO> Getifrmgrid(intprno)

{
List<ifrmPOCO> flist = new List<ifrmPOCO>();
List<ihtiyacfirma2POCO> flist2 = new List<ihtiyacfirma2POCO>();List<ihtiyacfirma2POCO> flist3 = new List<ihtiyacfirma2POCO>();

flist = (from q in ObjectContext.STN_ProfilFirma

where q.PF_PNo == prno

select new ifrmPOCO{

IF_FKod1 = q.PF_FirmaKodu,

}).ToList();

foreach (ifrmPOCO itemf in flist)

{
string frm = Convert.ToString(itemf.IF_FKod1);

flist2 = (from a in ObjectContext.STN_MUHANASQL
where a.MUH_KOD == frm
select new ihtiyacfirma2POCO{

IF_FirmaAdi = a.MUH_ADI,

}).ToList();

flist.Where(w => w.IF_FKod1 == itemf.IF_FKod1).First().IF_FirmaAdi = flist2.First().IF_FirmaAdi.ToString();
}

return

flist.AsQueryable();

}

 

Answers & Comments...




How to set Default File name in Save Dialogue box in silverlight 4

How to set Default File name in Save Dialogue box in silverlight 4

Hi,

I am using Silverligt 4 application. When I export by default file name should display in the save dialogue box. Please give me a c# code to achieve this in Silverlight 4 application. This is very high priority else give me alternate solution to achive in Silverlight 4 application.

Regards,

Santosh

Answers & Comments...

Answer: 1

That feature was added to the SaveFileDialog control in silverlight 5.  Here is a possible work around for silverlight 4 (I did not test):

http://stackoverflow.com/questions/8316799/silverlight-savefiledialog-set-default-file-name



Answer: 2

http://msdn.microsoft.com/en-us/library/system.windows.controls.savefiledialog%28v=vs.95%29.aspx

http://forums.silverlight.net/t/117702.aspx



Answer: 3

hi santoshhegde

private void nmrButton_Click(object sender, RoutedEventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.GetType().GetMethod("set_DefaultFileName").Invoke(dialog, new object[] { "FileName.ext" });
dialog.ShowDialog();
}

Thanks & Regards
Mastan Narravula
Mark as Answer", if it helped you or it might help others too.



Answer: 4

Hi,

This I tried I am getting object refernce not set to an instance of an object error.

Regards,

Santosh



Answer: 5

hi 

can u tell which item is getting null here...



Answer: 6

I have done like this:

SaveFileDialog objSFD = new SaveFileDialog() {
DefaultExt = "csv",
Filter = "CSV Files (*.csv)|*.csv|Excel XML (*.xml)|*.xml|All files (*.*)|*.*",
FilterIndex = 1
};

string item = TextBox.Text;

objSFD.GetType().GetMethod(item).Invoke(objSFD, new object[] { item });

Here item will contain text box value that value I want to keep as SaveDialogueBox default file name. Let me know  where I am doing wrong.

Regards,

Santosh



Answer: 7

hi santoshhegde keep this and try

objSFD.GetType().GetMethod("set_DefaultFileName").Invoke(objSFD, new object[] { "Mastan" });

Thanks & Regards
Mastan Narravula
Mark as Answer", if it helped you or it might help others too.



Answer: 8

Hi,

With that also I am getting same error : Object reference not set to an instance of an object.



Answer: 9

hi try this

private void nmrButton_Click(object sender, RoutedEventArgs e)
{
TextBox tb = new TextBox();
tb.Text = "NMR";

SaveFileDialog objSFD = new SaveFileDialog()
{
DefaultExt = "csv",
Filter = "CSV Files (*.csv)|*.csv|Excel XML (*.xml)|*.xml|All files (*.*)|*.*",
FilterIndex = 1
};

string item = tb.Text;

objSFD.GetType().GetMethod("set_DefaultFileName").Invoke(objSFD, new object[] { item.ToString() });
objSFD.ShowDialog();
}

Thanks & Regards 
Mastan Narravula
Mark as Answer", if it helped you or it might help others too.



Answer: 10

Hi Mastan,


No luck still I am getting same error.



Answer: 11

Hi,

I tried above one no luck still getting same issue.





Bind Font Family to Combobox

Bind Font Family to Combobox

how to Bind Font Family to Combobox?

Answers & Comments...

Answer: 1

Jigna Punjabi

how to Bind Font Family to Combobox?

There is no such option in silverlight to get the list of font families using either c# or xaml, there is one alternate.

follow this link

http://stackoverflow.com/questions/2705556/how-to-know-local-font-names-in-silverlight/3504446#3504446

I hope this might help you.





How to change Foreground color of Tabitem when IsEnabled = False

How to change Foreground color of Tabitem when IsEnabled = False

Hi,

In Silverlight 4 & Silverlight 5

I need to change the Foreground color of the TabItem.Text

When TabItem.IsEnabled = False. - i need to have it in RED color

also when TabItem.IsEnabled = True but not Selected i need different Color -  Say Orange Color

also when TabItem.IsEnabled = True but Selected i need different Color- Say Green Color

Thanks & Regards

Mayur Bheda

Answers & Comments...

Answer: 1

You have to write like this

tabItem.Foreground = new SolidColorBrush(Colors.Red);





How to set html host page size from c#

How to set html host page size from c#

I want to customize my html page size when i run the silverlght application.

Can anyone suggests me how to do?

Answers & Comments...

Answer: 1

you want to resize the browser window?  you can do that with javascript, but generally users don't like that.  if you need a window with a specific size, you should create a popup window for which you can specify any size you want without messing with the user's other tabs.

anyway, if you really must, you can create a javascript function that resizes the window (google knows how to do this).  then you can invoke that javascript method from your silverlight code (google knows how to do that too).





Embedding Silverlight Chart in ASP.Net Application

Embedding Silverlight Chart in ASP.Net Application

Hi ,

I have a  ASP.Net Application running. On a *.aspx page in this application i want to show a Silverlight Bar chart  .I know , i have to create a WCF To show the data in chart .

but how we can embed this Silverlight object in any aspx page in my already running ASP.Net Application.

What will we the process.?  

Answers & Comments...

Answer: 1

Just add a Silverlight App to your current solution. Then in the Web app properties, Silverlight tab, add your SL app to the list so the Xap will be deployed to server /ClientBin folder.

Then use the plugin with an object tag in your HTML page (ASP.NET page).

That's all.

If your SL app is needing some data, you will have to add an Entity Framework model to the Web app, select the source and tables to use, than add WCF Ria service to expose data (and add a client policy file to the root of you web app). In Silverlight App you will finally add a reference to the service and you'll be ready to use the data.

You can also use something simpler : the SL app can get its data from the parameters in the Html object tag... The ASP.NET page can then write with a bit C# scripting a "data" parameter to pass the data as a string ("12;54.2;85" for exemple). The SL App will just have to read the parameter and draw the chart without any need to access a data server...

 



Answer: 2

Hi,

In Column Series of Chart , I want to change the Style of ColumnSeries as Cylindrical(Cylinder).Is there inbuild method in Silverlight chart ? If not we can achieve it ?

Regards

Rajesh





Changing Style of ColumnSeries in Silverlight Chart of Toolkit

Changing Style of ColumnSeries in Silverlight Chart of Toolkit

Hi,

In Column Series of Chart , I want to change the Style of ColumnSeries as Cylindrical(Cylinder).Is there inbuild method in Silverlight chart ? If not, how  we can achieve it ?

Regards

Rajesh

Answers & Comments...




RichTextBox editor determine if selection is image

RichTextBox editor determine if selection is image

I have an editor similar to the one described here:

http://msdn.microsoft.com/en-us/library/ff426926(v=vs.95).aspx

I am trying to determine if the user's selection in the rtb is an image so they can edit the properties without deleting it and re-adding it.

I have already implemented this feature for a hyperlink with this code:

private void RichTextBoxEditor_SelectionChanged(object sender, RoutedEventArgs e)          {              Inline parent = this.RichTextBoxEditor.Selection.Start.Parent as Inline;              if (parent != null)              {                  Hyperlink hyperlink = parent.ElementStart.Parent as Hyperlink;                  if (hyperlink == null)                  {                      this.tbUrlEditor.Visibility = Visibility.Collapsed;                  }                  else                  {                      this.tbUrlEditor.Visibility = Visibility.Visible;                      this.tbUrlEditor.Text = hyperlink.NavigateUri.ToString();                  }              }            }

So, when the user's caret or selection is a hyperlink, they are able to edit its Uri in my TextBox "tbUrlEditor".

I am hoping to be able to do the same thing with an image, but I am not successful when I try the same approach.

Answers & Comments...

Answer: 1

bherdrick

So, when the user's caret or selection is a hyperlink, they are able to edit its Uri in my TextBox "tbUrlEditor".

I am hoping to be able to do the same thing with an image, but I am not successful when I try the same approach.

Hi bherdrick,

You can try to set a breakpoint at ( parent.ElementStart.Parent as Image) to find if there is retured an Image or not, it there is, you may try get the image's size or name.

Best Regards,



Answer: 2

Unfortunately, that doesn't work.  The breakpoint isn't hit when I try that.  The xaml that is generated for the hyperlink is in this form:

<Paragraph>      <Run FontFamily="Portable User Interface" FontSize="12" Text="Some text ">        <Run.Foreground>          <SolidColorBrush Color="#FF000000" />        </Run.Foreground>      </Run>      <Hyperlink FontSize="12" NavigateUri="/someuri.aspx" TargetName="_self" TextDecorations="Underline">        <Hyperlink.Foreground>          <SolidColorBrush Color="#FF01439A" />        </Hyperlink.Foreground>        <Run FontFamily="Portable User Interface" FontSize="12" Text="some uri text">          <Run.Foreground>            <SolidColorBrush Color="#FF01439A" />          </Run.Foreground>        </Run>        <Hyperlink.MouseOverForeground>          <SolidColorBrush Color="#FFED6E00" />        </Hyperlink.MouseOverForeground>      </Hyperlink>      <Run FontFamily="Portable User Interface" FontSize="12" Text="more text. ">        <Run.Foreground>          <SolidColorBrush Color="#FF000000" />        </Run.Foreground>      </Run>    </Paragraph>  

and for the image:

<Paragraph TextAlignment="Center">      <InlineUIContainer>        <Image Height="132" Source="http://www.mysite.com/myimage.png" Stretch="Uniform" Width="600" />      </InlineUIContainer>    </Paragraph>

When the image is selected in the RichTextBox, the "parent" is null.  I tried both 

Image imgParent = this.RichTextBoxEditor.Selection.Start.Parent as Image;
InlineUIContainer imgParent = this.RichTextBoxEditor.Selection.Start.Parent as InlineUIContainer;
Neither of those work either.





Answer: 3

Hi bherdrick,

What is the relative complete code of your RichTextBoxEditor? To troubleshoot this issue, we need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. You can remove any confidential information or business logic from it. You can upload the project in the skydrive and post the link here.

Best Regards,



Answer: 4

I sent you the link to it through a pm.





Silverlight Ftp Upload

Silverlight Ftp Upload

I'm working on trying to ftp a file to the server through a silverlight application. Where the location to upload the file on server file system, exists outside the sandbox area for the web server. In this case the web server root exists at "C:\test\www\" and the location to upload the file will exist at "C:\User\Uploads". In this scenerio i'm not sure if Http POST will work (doesn't that use the web server root). I just need to upload the file selected by the user to a different location that may exist outside the sandbox. With silverlight i'm thinking sockets are my last option based on the limited port range for silverlight being 4502-4532. Can i do this using WebClient and Http POST? Can i make an ftp connection through silverlight or javascript?

Answers & Comments...

Answer: 1

Assuming your server is ASP.NET based I would use a simple WebClient POST into a .ashx handler. Have the handler write the body of the post to a file in "C:\User\Uploads".

by : AnthonyWJoneshttp://stackoverflow.com/users/17516

Answer: 2

This is an interesting scenario, since it sounds like you are doing this all on the same machine (both client and server). I am responding to the vague original question, and would love additional data to help answer this completely.

FTP uploading itself is not supported by Silverlight, but the concept of uploading a file is, through an HTTP stream of data.

If you want to do an HTTP upload from a client machine to the server: You can use the OpenFileDialog control in Silverlight 2 and 3 to read that data, then use WebClient to upload it.

If you want to do a download from something your web server can send, to the client machine, then you'd need to use Silverlight 3 or newer, which features a SaveFileDialog control.

All Silverlight file dialogs require a user-initiated action for them to work, function, and the user will need to select the file name(s) for security purposes.

Hope this helps!

by : Jeff Wilcoxhttp://stackoverflow.com/users/66601

Answer: 3

As long as the ftp server is on the same host as the silverlight app you can use sockets and code your own ftp client, its not very hard and there's plenty of examples out there.

by : bar10drhttp://stackoverflow.com/users/313776

Answer: 4

In the meantime, name it Silverlight 5, Sockets got an update: with ClientAccessPolicy.xml the port-range got boosted and an in-browser elevated-trust mode is available.

Therefore I've created sharpLightFtp to enable rudimental Ftp.

by : Andreas Niedermairhttp://stackoverflow.com/users/57508




Questions when customize the header of a pivotitem

Questions when customize the header of a pivotitem

try to customize the header of each PivotItem, i google first and write code below, this is OK:

<controls:Pivot Title="MyPivot">     <!--Pivot item one-->     <controls:PivotItem>         <controls:PivotItem.Header>             <TextBlock Text="Pivot1" FontSize="40"/>         </controls:PivotItem.Header>         <Grid/>     </controls:PivotItem> </controls:Pivot> 

when I add the second pivot item in this way, an error appears as "Value does not fall within the expected range.",the error starts from [controls:PivotItem] of "pivot item two",

<controls:Pivot Title="MyPivot">     <!--Pivot item one-->     <controls:PivotItem>         <controls:PivotItem.Header>             <TextBlock Text="Pivot1" FontSize="40"/>         </controls:PivotItem.Header>         <Grid/>     </controls:PivotItem>      <!--Pivot item two-->     <controls:PivotItem>         <controls:PivotItem.Header>             <TextBlock Text="Pivot2" FontSize="40"/>         </controls:PivotItem.Header>         <Grid/>     </controls:PivotItem> </controls:Pivot> 

When I build the project, the error just gone away, and the whole app runs like a charm. But everytime i add a new pivot item in this way, the error shows up.

My questions are:

  1. why does this error happen and how to solve it?
  2. can I ignore this error?

Answers & Comments...

Answer: 1

This "error" it's thrown just at design-time, and I think you can ignore it....also because it will go definitively away the first time you build the project (so, it means there are no real problems in your project - and also no warnings)!

There are more of this type of errors thrown by the designer.

Ignore it!

by : MAXEhttp://stackoverflow.com/users/833644




How do I disable validation in a Silverlight 4 application?

How do I disable validation in a Silverlight 4 application?

update How do I disable validation in a Silverlight 4 application? It looks like this is something not unique to RIA Services (as my original question below implies). I observe this when I bind my datagrid to a list of POCOs and I trigger a validation error in my grid (e.g. typing in a non-numeric in a cell bound to a numeric property). How does one disable the validation in this instance? end update

How do I disable (turn off) validation in a grid that is bound to classes generated by RIA Services in my Silverlight application. I would like to disable validation just for this grid; there are other controls where I would like to use validation.

e.g. Let's say I've got a RIA services generated class called Customer with the fields: ID, FirstName, LastName. All the corresponding fields in my Customer table in the database are not nullable (thus, required). A collection of the Customer classes are bound to a grid:

myGrid.itemsSource = myListOfCustomers 

And for each column in my grid, I've defined a binding to one of the properties, e.g.

="{Binding FirstName}" 

I'd like my user to be able to enter anything in any of the cells in my grid without the validation messages from appearing. e.g. Right now, entering a non-numeric in my integer ID column results in a validation message being displayed.

I've got an application set up with RIA Services, Entity Framework 4, and Silverlight 4. It is set up in the standard fashion prescribed on MSDN here: Walkthrough: Creating a RIA Services Solution

Thanks in advanced.

Answers & Comments...

Answer: 1

A bit late, but did you try to set the NotifyOnValidationError and related properties on the bindings to false?

by : aKzenThttp://stackoverflow.com/users/679886




silerverlite is web devlopment language or window application?

silerverlite is web devlopment language or window application?

I am new in this techology. Actually i am confused silverlite is web devlopment language or desktop application or both?

can i devlop web site using silverlite?

Answers & Comments...




Building a canvas template in WP7

Building a canvas template in WP7

    I'm attempting to build a golf game tracking program that uses a canvas to hold an arranged set of buttons and databound items for each player. Because the number of people in a game is dynamic, I need to be able to build the canvases on the fly and bind them on the fly as well. the problem I'm having is setting up the databinding. If I attempt to bind in code then the text for the binding (text={Binding}) always comes out as though it were a string literal instead of an actual binding. To get around this I attempted to build a template of the canvas, but I can't find a way to actually apply the template to a new canvas as I build out new players.

    So with all that in mind, what is the best way to either A) build a template canvas with all my controls so I can just copy and bind to each player, or B) build the text bindings dynamically without having to resort to XAML?

Edit: The following was added for clarification on how I'm creating a textblock.

TextBlock newBlock = new TextBlock         {             Text = "{Binding}",             FontSize = 42,             DataContext = Player.SomeStat,             Name = Player.PlayerName ,          }; 

The value shown on the screen for the textblock (instead of what it should be) is: {Binding}

Answers & Comments...

Answer: 1

To create a Binding in code you need to go some extra steps:

object myDataObject = DataContext; Binding myBinding = new Binding(); myBinding.Source = myDataObject; myBinding.Path="."; // not sure if required newBlock.SetBinding(TextBlock.TextProperty, myBinding); 
by : HDW Productionhttp://stackoverflow.com/users/1393983




Confused about windows gadget

Confused about windows gadget

I have developed a Windows desktop gadget using Silverlight (MVVM pattern) and WCF.

I want to know whether it will work on Windows 8, since there is no option as sidebar in Windows 8.

If possible please tell what should I do to make it compatible with both Windows 7 and Windows 8.

Answers & Comments...

Answer: 1

Windows Desktop Gadgets are not supported on Win8: http://www.techradar.com/news/software/operating-systems/microsoft-to-remove-desktop-gadgets-from-windows-8-1088122

by : Robhttp://stackoverflow.com/users/1146887

Answer: 2

You can try to reuse some parts of your code to make a Windows 8 'immersive app' with a Live Tile. The C#/XAML stack in Windows 8 is quite similar to Silverlight (but not the same). See http://msdn.microsoft.com/en-us/library/windows/apps/hh465136.aspx for a guide about the differences.

by : jv42http://stackoverflow.com/users/428381




Binding two different Collection Source in Pivotviewer

Binding two different Collection Source in Pivotviewer

I'm trying to understand how to manage a transition between two collections in pivotviewer. Collections have the same images, it's just that one collection is processed. I want to have one collection vanishing into the other.

I know how to define different templates that vanishes one into the other by fixing the maxwidth. For example once you zoom over 300 px then you have your new template until you reach 500 px, etc. The code I use to bind the collection I've loaded in the code behind is like this:

<pv:PivotViewerItemTemplate x:Key="firstTemplate" MaxWidth="300">     <!-- template layout -->     <pv:PivotViewerMultiScaleSubImageHost CollectionSource="{Binding [VisualCollectionSource][0] }"  ImageId="{Binding [VisualImageId][0]}" />     <!-- template layout --> </pv:PivotViewerItemTemplate> 

Is there a solution like this I can adopt? What's the best practice for it?

Answers & Comments...




Why data is not showing in Network machines for a silverlight website?

Why data is not showing in Network machines for a silverlight website?

I have a silverlight web application with a WCF service to access a table in sql server DB. In this application, I am showing a List fetched from a table in sql server DB using a WCF service into my silverlight CumboBox.

Notes:- SQLServer DB is in a remote machine. Silverlight website hosted in IIS Version: 5.1 in another remote machine. WCF Service is added as a servicereferance client to the Silverlight website on the same machine.

While I am running the silverlight website in the same machine where it is hosted, its working fine for me and is giving the expected output. But the same website while accessing from other remote machines its showing the website with control having no data in it as shown in the Images.image in the same machine where Silverlight web site hostedimage in the other remote machine connected through LAN

Can any body tell me what might be the problem. I am new to WCF Services so please let me know if I need to share more info in this question.


Update-1:- *clientaccesspolicy.xml*

<?xml version="1.0" encoding="utf-8" ?> <access-policy>     <cross-domain-access>         <policy>             <allow-from http-request-headers="SOAPAction">                 <domain uri="*"/>             </allow-from>             <grant-to>                 <resource path="/" include-subpaths="true"/>             </grant-to>         </policy>     </cross-domain-access> </access-policy> 

Update-2 I tried by adding the crossdomain.xml file to my WCF service project as well as to the root(i.e. http://10.30.10.42:8080/DICOMWebViewer/crossdomain.xml) also, but the issue is still there. Can any body help me to find out the problem please.

crossdomain.xml:-

<?xml version="1.0"?> <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> <cross-domain-policy>     <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/> </cross-domain-policy> 

Update-3:- I have gone through Able to see Silverlight content on Local IIS but not remotely RSS, but no luck again. I am still facing the same problem.

Answers & Comments...

Answer: 1

Chances are good you have to configure the crossdomain policy for your setup to work, checkout the following msdn article.

by : Dominikhttp://stackoverflow.com/users/782758

Answer: 2

I fixed the problem by hosting the WCF web service in IIS server. Previously it was in the localhost, that's why remote machines were not able to download the crossdomain policy and client access policy and also the service was completely unknown to the remote machine. Because of what controls were not getting data neither from the SQL Server DB nor from the XML file. Now its working fine. Thank you Dominik for your quick answers.

by : SharpUrBrainhttp://stackoverflow.com/users/384353




How to maintain state in a Silverlight 5 application?

How to maintain state in a Silverlight 5 application?

I am new to silverlight. I got a login page and after the user logs in i want to maintain the user name and details within the application. How to achieve this?

Answers & Comments...

Answer: 1

Use cookies.

Silverlight Tip of the Day #18: How to Set Browser Cookies.
How to: Get and Set Cookies.

by : Dennishttp://stackoverflow.com/users/580053




Custom pie chart colors with legend in Silverlight Toolkit

Custom pie chart colors with legend in Silverlight Toolkit

Each data series in my pie chart should have a specific color that is defined in an object. Thanks to this question I've managed to achieve this, but there's a problem - legend doesn't have updated colors.

To this point I've created ControlTemplate for legend and bound Fill property to IndependentValue, just like in SliceTemplate. It looks like this:

<charting:PieSeries DependentValuePath="Value" IndependentValuePath="Key" x:Name="pieChart" ItemsSource="{Binding}">     <charting:PieSeries.Resources>         <local:ColorKeyToColorConverter x:Key="ColorKeyToColorConverter" />         <ControlTemplate x:Key="SliceTemplate" TargetType="charting:PieDataPoint">             <Path Data="{TemplateBinding Geometry}"                 Fill="{Binding RelativeSource={RelativeSource TemplatedParent},                 Path=IndependentValue,                  Converter={StaticResource ColorKeyToColorConverter} }"                 Stroke="{TemplateBinding BorderBrush}" />         </ControlTemplate>         <ControlTemplate x:Key="LegendTemplate" TargetType="charting:LegendItem">             <Border Background="{TemplateBinding Background}"                     BorderBrush="{TemplateBinding BorderBrush}"                     BorderThickness="{TemplateBinding BorderThickness}">                 <StackPanel Orientation="Horizontal" VerticalAlignment="Center" Margin="2,2,5,2">                     <Rectangle Width="8" Height="8"                                Fill="{Binding RelativeSource={RelativeSource AncestorType=charting:PieSeries, AncestorLevel=1},                                      Path=IndependentValue, Converter={StaticResource ColorKeyToColorConverter}}"                                Stroke="{TemplateBinding BorderBrush}"                                StrokeThickness="1" Margin="0,0,3,0" VerticalAlignment="Center" />                     <datavis:Title Content="{TemplateBinding Content}"  VerticalAlignment="Center"/>                 </StackPanel>             </Border>         </ControlTemplate>     </charting:PieSeries.Resources> 

Pie chart works fine, but unfortunately, colors in legend aren't updating and they're transparent (by default they are yellow, so template binding works, but it doesn't bind colors properly).

What's wrong then? SliceTemplate has a Path object, but I'm not sure how to use it in LegendTemplate. I don't know if it's the problem.

Any help would be appreciated.

Answers & Comments...




Request from Silvelight App takes long time to reach WCF Server

Request from Silvelight App takes long time to reach WCF Server

I am using Silverlight to build a test app getting data from a WCF Service. I'm wonder why the request silverlight app sent out takes a very long time (68-70 seconds) to reach WCF Server even though the data size just 80KB. Could you please tell me how can I get that speed up? I am using basicHttpBinding, anything missing in the config file I should double check?

Thank you much! khoailang

Answers & Comments...




Dynamically load images from database and display in Silverlight 3 image rotator

Dynamically load images from database and display in Silverlight 3 image rotator

I have a Silverlight 3 image rotator that displays approx.7 images. You can rotate it back and forth, and it will make the left or right image the selected image. The rotator is using jpg images that resides in an image folder. I would like to dynamically load image strings from the database, since I have hundreds of images available. My question is: How can I load a list or collection based on a query, convert the image strings into Pictures and load them into the rotator dynamically. here is what I have now.

XAML

<UserControl     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:vc="clr-namespace:Visifire.Charts;assembly=SLVisifire.Charts"                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"      mc:Ignorable="d"      xmlns:CollectionFlow="clr-namespace:CollectionFlow;assembly=CollectionFlow"      x:Class="CollectionFlowSample.MainPage"     d:DesignWidth="640" d:DesignHeight="480" Loaded="UserControl_Loaded" Width="900" Height="800">     <UserControl.Resources>     	<DataTemplate x:Key="DataTemplate1">     		<Grid RenderTransformOrigin="0.5,0.5">     			<Grid.RenderTransform>     				<TransformGroup>     					<ScaleTransform/>     					<SkewTransform/>     					<RotateTransform/>     					<TranslateTransform Y="100"/>     				</TransformGroup>     			</Grid.RenderTransform>     			<Grid.RowDefinitions>     				<RowDefinition/>     				<RowDefinition Height="5"/>     				<RowDefinition/>     			</Grid.RowDefinitions>                      <Border Height="180"      				HorizontalAlignment="Left" VerticalAlignment="Top"      				Width="140" BorderThickness="10" Margin="16,14,0,0"                         CornerRadius="2">                     <Border.BorderBrush>                         <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                             <GradientStop Color="Black" Offset="0"/>                             <GradientStop Color="#FF282323" Offset="1"/>                             <GradientStop Color="#FF413636" Offset="0.556"/>                             <GradientStop Color="#FFCEBABA" Offset="0.83"/>                         </LinearGradientBrush>                     </Border.BorderBrush>                     <Image Source="{Binding Mode=OneWay}" Stretch="Fill" >     				<Image.Effect>     					<DropShadowEffect ShadowDepth="0" BlurRadius="3" Opacity="0.5"/>     				</Image.Effect>     			</Image>                         </Border>     			<Image Source="{Binding Mode=OneWay}" Grid.Row="2" RenderTransformOrigin="0.5,0.5">     				<Image.Effect>     					<BlurEffect/>     				</Image.Effect>     				<Image.OpacityMask>     					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">     						<GradientStop Offset="0.5"/>     						<GradientStop Offset="1" Color="#7F000000"/>     					</LinearGradientBrush>     				</Image.OpacityMask>     				<Image.RenderTransform>     					<TransformGroup>     						<ScaleTransform ScaleY="-1"/>     						<SkewTransform AngleX="0" AngleY="0"/>     						<RotateTransform Angle="0"/>     						<TranslateTransform/>     					</TransformGroup>     				</Image.RenderTransform>     			</Image>               </Grid>     	</DataTemplate>     	<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">     		<CollectionFlow:CollectionFlowPanel ItemHeight="400" ItemWidth="160" FocusedItemOffset="60" UnfocusedItemOffset="40" ItemVisibility="5" RenderTransformOrigin="0.5,0.5"/>     	</ItemsPanelTemplate>     </UserControl.Resources>   <Grid x:Name="LayoutRoot">         <Grid.Background>             <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">                 <GradientStop Color="#FFA0A0A0" Offset="0"/>                 <GradientStop Color="Black" Offset="1"/>             </LinearGradientBrush>         </Grid.Background>              <CollectionFlow:CollectionFlow x:Name="ImageList" ItemTemplate="{StaticResource DataTemplate1}" ItemsPanel="{StaticResource ItemsPanelTemplate1}">             <CollectionFlow:CollectionFlow.Background>             	<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">             		<GradientStop Color="#FFEAE2E2"/>             		<GradientStop Color="#FF0E0101" Offset="1"/>             		<GradientStop Color="#FF676464" Offset="0.665"/>             	</LinearGradientBrush>             </CollectionFlow:CollectionFlow.Background>          </CollectionFlow:CollectionFlow> 

C# code

ImageList.ItemsSource = new string[] {"SampleImages/10019436.jpg","SampleImages/10042172.jpg" etc... 

Here is what like to do..... Query Database get records back and then...

use the conversion function process...

string sPic = (string)emps.Photo.ToString();  EmpPic1.Source = ConvertBase64ToImage(sPic);  public BitmapImage ConvertBase64ToImage(string base64String) {         //Convert Base64 String to byte[]         byte[] imageBytes = Convert.FromBase64String(base64String);         BitmapImage bi = new BitmapImage();         bi.SetSource(new MemoryStream(imageBytes));         return bi; } 

This is where I like to add the queried images to a collection,and use the technique described above to dispaly them in the image rotator.

Any help would be appreciated.

Answers & Comments...

Answer: 1

you need to request data using a web server (through a web service call is a good way of achieving this) this will return the data to your silverlight application, you wont be able to connect to a database directly with silverlight, your service will access the database and it can then return the data to your application to be consumed by the code you discussed above.

Create a web service that returns the image data add a web reference to your silverlight application that points to your service use the generated proxy to call the service and return the data to your application - you could either use the serviceclient of the proxy with an asynchronous call back or forget the proxy and just call the service using webclient

i think its important to understand the client based nature of silverlight, it lives in a sandbox on a remote computer in its most typical use case, so accessing data doesnt use the same approach as say a windows forms application>

by : Matthttp://stackoverflow.com/users/53271




How can I change the ComboBox "selectedIndex" on WebBrowser on Silverlight for Windows Phone?

How can I change the ComboBox "selectedIndex" on WebBrowser on Silverlight for Windows Phone?

In the WebBrowser there is this page (http://gttweb.5t.torino.it/gtt/en/percorsi/percorsi-ricerca.jsp) and there is the "destinationCity" ComboBox. In VB.NET I use:

Dim DestinationComboBox As HtmlElement = MainWebBrowser.Document.All.Item("destinationCity") DestinationComboBox.SetAttribute("selectedindex", 1) 

to change the ComboBox selectedIndex, but in Silverlight (in this WebBrowser) there's only the InvokeScript function.. How can I change the selectedIndex using InvokeScript()? I've tried

InvokeScript("eval", "document.getElementById('destinationCity').selectedindex = 4") 

But it doesn't work.. Help please!

Answers & Comments...

Answer: 1

If you use Chrome Developer Tools, or FireBug to execute the following JavaScript against the given page, you will find that it does not work in a desktop browser:

document.getElementById('destinationCity').selectedindex = 4 

JavaScript, and the selectedIndex property are case sensitive. The following works:

document.getElementById('destinationCity').selectedIndex = 4 
by : ColinEhttp://stackoverflow.com/users/249933




Set querystring when creating new instance of a page in code behind

Set querystring when creating new instance of a page in code behind

In a Silverlight application page I've created a new instance of another page.

MyPage2 Pippo = new MyPage2(); 

In the MyPage2 OnNavigatedTo event I do some stuff depending on the query string.

How can I pass a query string when creating a page like before?

Thanks in advance,

Bye ;)

Answers & Comments...

Answer: 1

I think your problem is based on "bad" design... I do not know what you want to do but if there is anything that gets calculated or loaded from wherever on your "MyPage2", why dont you exctract this code and use it wherever you need this information?

by : Dominik Kirschenhoferhttp://stackoverflow.com/users/725472




How to import a .rtf file to silverlight 4 richtextbox?

How to import a .rtf file to silverlight 4 richtextbox?

I have a .rtf file and want to put it in a richtextbox in silverlight 4. Unfortunately we do not have .rtf property in silverlight 4 richtextbox, we only have .xaml.

So what i did is to create a FlowDocument, than load the .rtf to this FlowDocument, then format it to xaml. then assigned it to richtextbox. But i got a argumentexception.

How to import a .rtf file to silverlight 4 richtextbox?

Thanks!

Answers & Comments...

Answer: 1

I used an ugly solution so far, use a FlowDocument to change the format from rtf to xaml. Then remove the attributes not accepted in SL4 richtext box, codes like below. It works but I hate it. I want to know is there a better solution.

        string xaml = String.Empty;         FlowDocument doc = new FlowDocument();         TextRange range = new TextRange(doc.ContentStart, doc.ContentEnd);          using (MemoryStream ms = new MemoryStream())         {             using(StreamWriter sw = new StreamWriter(ms))             {                 sw.Write(from);                 sw.Flush();                 ms.Seek(0, SeekOrigin.Begin);                 range.Load(ms, DataFormats.Rtf);             }         }           using(MemoryStream ms = new MemoryStream())         {             range = new TextRange(doc.ContentStart, doc.ContentEnd);              range.Save(ms, DataFormats.Xaml);             ms.Seek(0, SeekOrigin.Begin);             using (StreamReader sr = new StreamReader(ms))             {                 xaml = sr.ReadToEnd();             }         }          // remove all attribuites in section and remove attribute margin           int start = xaml.IndexOf("<Section");         int stop = xaml.IndexOf(">") + 1;          string section = xaml.Substring(start, stop);          xaml = xaml.Replace(section, "<Section xml:space=\"preserve\" HasTrailingParagraphBreakOnPaste=\"False\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">");         xaml = xaml.Replace("Margin=\"0,0,0,0\"", String.Empty); 
by : freskyhttp://stackoverflow.com/users/304115

Answer: 2

I suggest you take a look at the free VectorLight Rich Text Box control instead.

by : AnthonyWJoneshttp://stackoverflow.com/users/17516

Answer: 3

I need to do something similar (haven't done it yet ...)

I came across NRTFTRee, a C# RTF parser, which should port to silverlight. http://www.codeproject.com/KB/string/nrtftree.aspx

http://nrtftree.sourceforge.net/examples.html

by : Doobihttp://stackoverflow.com/users/308687




Dynamically Accessing MainPage controls in child UserControl's from codebehind in metro application?

Dynamically Accessing MainPage controls in child UserControl's from codebehind in metro application?

i have a MainPage in which part of the screen i have empty grid named customview , in which i want to dynamically add and remove different views(different usercontrols). now i have attached one usercontrol(view1) to that empty grid(part of the MainPage) in this way :- customview is the empty grid , view1 is the usercontrol which i have designed,and on navigated to MainPage i am doing this :-

protected override void OnNavigatedTo(NavigationEventArgs e) { customview.Children.Clear(); View1 firstview = new View1 (); customview.Children.Add(firstview);  } 

Now , View1 (usercontrol) is having a button1 , on that button1 click i have to remove view1 and add view2 (another user control) to the same grid named customview present in MainPage.

which i have tried it in this way but no luck :-

private void button1_Click_1(object sender, RoutedEventArgs e) { MainPage main = new MainPage(); View2 secview = new View2 (); Grid grd = main.FindName("customview") as Grid; grd .Children.Clear(); grd .Children.Add(secview); } 

Please let me know where am i doing wrong ? Thanks in advance.

Answers & Comments...

Answer: 1
Label lbl = (Label)this.Page.FindControl("controlID"); string labelText = lbl.Text; 
by : Ankush Jainhttp://stackoverflow.com/users/1372444

Answer: 2

Consider the using of ContentControl instead of doing this way. Using that you'll be able to change its Content, adding wherever you want.

add this to your view :

            <ContentControl Name="region1ContentControl"                          Grid.Row="1"                         Grid.Column="1"                         Margin="0,10"                                                    Style="{StaticResource ContentControlStyle}" /> 

so on code behind you'll be able to do like this:

region1ContentControl.Content = AnyObject(including views) 

This will be easier to work than changing views all the time.

Hope it helps

by : Viniciushttp://stackoverflow.com/users/1141477




How to get ClientCredentials from a Silverlight app?

How to get ClientCredentials from a Silverlight app?

I have a Silverlight 5 app which connects to a WCF service that is secured using Integrated Security (in IIS).

How can I set the ClientCredentials in the WCF proxy before I call a method or function from the WCF service (proxy) ?

Answers & Comments...




Parsing Twitter API to HubTile in Windows Phone [closed]

Parsing Twitter API to HubTile in Windows Phone [closed]

anyone know how to parse twitter API to HubTile in Windows Phone?

No Answer and comments so far




Is it possible to create a Windows 7 phone app in Ubuntu?

Is it possible to create a Windows 7 phone app in Ubuntu?

I'm able to run c# programs in Ubuntu using the mono project.

But I'd like to know whether it's it possible to create a Windows 7 phone app in Ubuntu.

If so, what packages do I need to install?

Answers & Comments...

Answer: 1

At the moment, no.

I tried to run Visual Studio 2010 Express for Windows Phone ( http://www.microsoft.com/visualstudio/en-us/products/2010-editions/windows-phone-developer-tools ) via Wine before but it failed to work properly without giving me problems. On top of that, you will still need Zune to allow deployment of app.

by : Guo Hong Limhttp://stackoverflow.com/users/641123




Programatically zoom out webpage in webbrowser

Programatically zoom out webpage in webbrowser

In my application I have created a webbrowser in which the page loads in Zoomed view.I need the page in zoomout position in default.Is it possible.Please help me.

Answers & Comments...

Answer: 1

The best way to do that is with Javascript. You can run the script from C#.

Here you have a sample: http://blogs.msdn.com/b/mikeormond/archive/2010/08/26/calling-javascript-functions-in-windows-phone-7.aspx

by : Aerilyshttp://stackoverflow.com/users/1473024




WCF >> DUPLEX >> SILVERLIGHT >> pollingDuplexHttpBinding = VERY SLOW ! BIG DELAY

WCF >> DUPLEX >> SILVERLIGHT >> pollingDuplexHttpBinding = VERY SLOW ! BIG DELAY

I have

WCF with wsDualHttpBinding binding for WPF applciation --> works good ! get WCF publish mthods immediately.

another binding with pollingDuplexHttpBinding for silvelight 4 --> very slow --> 30++- seconds delay after the wpf application got it ( the WPF gets it immediately )

Why is that ? best google result was

http://blogs.msdn.com/b/silverlightws/archive/2009/09/30/having-a-pollingduplex-service-and-any-other-wcf-service-in-the-same-website-causes-silverlight-calls-to-be-slow.aspx

which I didn't really know how to contiune ...

<system.serviceModel>      <!-- Register the binding extension from the SDK. -->     <extensions>       <bindingExtensions>         <add name="pollingDuplexHttpBinding"              type="System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement,                    System.ServiceModel.PollingDuplex,                     Version=4.0.0.0,                     Culture=neutral,                     PublicKeyToken=31bf3856ad364e35" />       </bindingExtensions>     </extensions>      <bindings>       <wsDualHttpBinding>         <binding name="wsDualHttpBinding"                  maxBufferPoolSize="2147483647"                  maxReceivedMessageSize="2147483647">           <readerQuotas maxDepth="2147483647"                         maxStringContentLength="2147483646"                         maxArrayLength="2147483646"                         maxBytesPerRead="2147483647"                         maxNameTableCharCount="2147483647" />         </binding>       </wsDualHttpBinding>       <pollingDuplexHttpBinding>         <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"                  duplexMode="MultipleMessagesPerPoll"                  maxOutputDelay="00:00:30"                  maxBufferPoolSize="2147483647"                  maxReceivedMessageSize="2147483647">           <readerQuotas maxDepth="2147483647"                         maxStringContentLength="2147483646"                         maxArrayLength="2147483646"                         maxBytesPerRead="2147483647"                         maxNameTableCharCount="2147483647" />         </binding>       </pollingDuplexHttpBinding>     </bindings>        <services>       <service behaviorConfiguration="" name="TheWCFService.Service1">          <endpoint address="wsDualHttpBinding"                   binding="wsDualHttpBinding"                   bindingConfiguration="wsDualHttpBinding"                   contract="TheWCFService.IService1">           <identity>             <dns value="localhost" />           </identity>         </endpoint>          <endpoint           address="mex"           binding="mexHttpBinding"           bindingConfiguration=""           contract="IMetadataExchange" />          <endpoint            address="pollingDuplexHttpBinding"            binding="pollingDuplexHttpBinding"            bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"            contract="TheWCFService.IService1">         </endpoint>          <host>           <baseAddresses>             <add baseAddress="http://localhost:8732/Service1/" />           </baseAddresses>         </host>        </service>     </services>      <behaviors>       <serviceBehaviors>         <behavior name="">           <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->           <serviceMetadata httpGetEnabled="true" />           <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->           <serviceDebug includeExceptionDetailInFaults="true" />           <dataContractSerializer maxItemsInObjectGraph="6553600"/>           <serviceThrottling maxConcurrentSessions="500" maxConcurrentCalls="500" maxConcurrentInstances="500" />         </behavior>       </serviceBehaviors>     </behaviors>      <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />   </system.serviceModel> 

Answers & Comments...




WPF binding not working properly with properties of int type

WPF binding not working properly with properties of int type

I am having a property of int type in my view model which is bound to a TextBox. Everything works properly, TwoWay binding works fine except in one case -

If I clear the value of TextBox, property setter doesn't gets called and although value is cleared in TextBox, property still holds the previous value.

has anyone faced similar issue? is there any workaround for this?

Here is the property -

public int MaxOccurrences {     get     {         return this.maxOccurrences;     }     set     {         if (this.maxOccurrences != value)         {             this.maxOccurrences = value;             base.RaisePropertyChanged("MaxOccurrences");         }     } } 

Here is how I am binding the property in xaml -

<TextBox Text="{Binding Path=MaxOccurrences, Mode=TwoWay,      NotifyOnSourceUpdated=True, UpdateSourceTrigger=PropertyChanged}"      HorizontalAlignment="Center" Width="30" Margin="0,0,5,0"/> 

Answers & Comments...

Answer: 1

This is partially a guess (I haven't got VS handy right now to try it out), but I think it's because a cleared text box is an empty string (""), which can't be implicitly converted to an int. You should probably implemented a type converter to provide the conversion for you. (you probably want to do something like convert "" to 0)

by : Simon P Stevenshttp://stackoverflow.com/users/119738

Answer: 2

It's because an int value can't be null. It's best to use a string property that converts the value for you within your code to the required int property field.

That way you can perform a

if(string.IsNullOrEmpty(text)) {   this.intValue = 0; } 
by : ChrisBDhttp://stackoverflow.com/users/102238

Answer: 3

I had the similar problem.

You just need to update the code as:

<TextBox Text="{Binding Path=MaxOccurrences, Mode=TwoWay, TargetNullValue={x:Static sys:String.Empty}, NotifyOnSourceUpdated=True,  UpdateSourceTrigger=PropertyChanged}"   HorizontalAlignment="Center" Width="30" Margin="0,0,5,0"/>  
by : WPF Userhttp://stackoverflow.com/users/355820

Answer: 4

Akjoshi, I have a working solution! You need to change your integer property to Naullable (i.e. int? ), see the following snippet:

private int? _maxOccurrences; public int? MaxOccurrences {     get { return _maxOccurrences; }     set { _maxOccurrences = value; } } 

You also need to add a value converter to convert the empty string to null value, see the following code snippet:

public class EmptyStringToNullConverter : IValueConverter {     #region IValueConverter Members      public object Convert(object value, Type targetType, object parameter, CultureInfo culture)     {         return value;     }      public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)     {         return value == null || string.IsNullOrEmpty(value.ToString())             ? null             : value;     }      

Silverlight, SignalR and IIS Applications off of the Default Web Site

Silverlight, SignalR and IIS Applications off of the Default Web Site

I'm using SignalR in a Silverlight 5 application. When I host my app in an "application" off of the default website in IIS 7.5 (i.e. localhost/subsite) Fiddler shows I get a 404 for "/signalr/negotiate".

It doesn't seem to take the IIS application path into account. It should be requesting "/subsite/signalr/negotiate". How do I get it to use the correct url prefix?

Update: I had to use the following code because it seems to be difficult to get the real root URI in a silverlight app without doing some parsing.

string xapLocationUri = Application.Current.Host.Source.AbsoluteUri;    string rootUri = xapLocationUri.Substring(0, xapLocationUri.IndexOf("/ClientBin"));    hubConnection = new HubConnection(rootUri);   

You can't really rely on the following if you're hosted in an application off of the root web site in IIS:

Application.Current.Host.Source.GetComponents(UriComponents.Scheme | UriComponents.HostAndPort, UriFormat.Unescaped)   

Answers & Comments...




Silverlight and Modal Windows

Silverlight and Modal Windows

I have the following situation: silverlight application, from main window I run the second window, and choose the product asotyment, I click ok and move on to the next screen where I choose the quantity, the price, etc.. All values ​​are stored and I got to the end automatically appear in the main window. The problem is that the windows appearing are not really modal and the main interface isn't waiting for appearing windows.

Answers & Comments...




Possible to Merge Segments of Silverlight Smooth Streaming?

Possible to Merge Segments of Silverlight Smooth Streaming?

Is it possible to merge two or three segments generated by a silverlight smooth streaming encoder?

I was at a LIVE event, and over the course of two hours, the bitrate dropped off at the encoding level which stopped the live encoding for a whole segment of that two hours. Now that two hours has been turned into 4 segments. Each with a different ISM file and video files. I am wondering if its at all possible or what would be the best solution to move forward?

I need the user who is watching the video only to see the one segment even though the server created four.

Please help. If I am not able to merge all the video together, is there a second solution that is possible?

Thank you in advance.

Answers & Comments...