|
While trying to find a solution to this problem, I read from somewhere that SSL to non-secured service calls would be denied. I could not be sure, but if it is not the case, you might have something there Nigel.
Going back to topic, I would appreciate any suggestions and help on this matter. Is there anyway to switch from HTTP to HTTPS while not losing silverlight page contents?
|
|
|
|
|
Soulforged wrote: SSL to non-secured service calls would be denied
That's the basis of the problem. By having the clientaccesspolicy.xml with https and http included you are allowing calls from a Silverlight app in http to services in https and vice versa. It is my understanding that the browser is ignorant of what Silverlight is doing in the background so the padlock can be misleading. You could run the app in https with a nice padlock and then call services over http and the padlock will stay there. Unless you remove/alter the clientaccesspolicy.xml and stick to either all http or all https.
I'll let you know if I find out any more info.
Cheers
|
|
|
|
|
Hi,
I am working on a WPF application,
one of my wpf windows has Listbox -> stackpanel -> Image and text block.
Let me put my xaml for better understanding
------------------------
<ListBox Name="listboxImage" HorizontalContentAlignment="Center" DataContext="Binding Element=listBinding,Path=SelectedItem" SelectionChanged="listboxImage_SelectionChanged"><!-- --><br />
<ListBox.ItemTemplate><br />
<DataTemplate x:Name="dtTemplate"><br />
<StackPanel Orientation="Vertical" Name="stackpnl"><br />
<Image Name="imagelisted" Source="C:\Casket.png"/> <br />
<TextBlock Name="textblockProductID" Text="{Binding Path=ProductID}"/><br />
</StackPanel><br />
</DataTemplate><br />
</ListBox.ItemTemplate><br />
</ListBox>
----------------------
Here is what I am trying to do behind the scene
-----------------
Binding listBinding = new Binding();<br />
listBinding.Source = ds.Tables[0];<br />
listboxImage.SetBinding(ListBox.ItemsSourceProperty, listBinding);<br />
listboxImage.SelectedIndex = 0;<br />
<br />
byte[] bytes = (byte[])ds.Tables[0].Rows[0][1];<br />
<br />
MemoryStream stream = new MemoryStream();<br />
stream.Write(bytes, 20, bytes.Length - 20);<br />
<br />
<br />
PngBitmapDecoder decoder = new PngBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);<br />
ImageSource source = decoder.Frames[0];<br />
<br />
this.imageTest.Source = source;
-----------------
Please, note that imageTest is the TestImage I have put outside the listbox, which works fine.
Now, Of course I am not setting Image's Source property "???????" but, in place of that
I want to set that property dynemically form code, as I am twicking the byte[] field.
So again, my question is how can I set source property to something from the code?
I have object of ImageSource ready,
So all I have to do is my "(from ListBox)ImageName.Srouce = myobject Of ImageSource Type.
I am new to WPF and DataBinding with it.
|
|
|
|
|
You could try making an IValueConverter that turns a byte[] into an ImageSource. Then you could say
<!-- put this in the resources section of the window
or usercontrol
(assuming you make a class called
ByteArrayToImageSourceConverter and the namespace
it is in is mapped to local in XAML) -->
<local:ByteArrayToImageSourceConverter
x:Key="B2IConv" />
<!-- put this in the list box item template -->
<Image Source="{Binding ByteArrayProperty Converter={StaticResource B2IConv}} />
It looks like you already have the code for converting a byte array to an image source, so all you have to do is look up the methods for IValueConverter and you should be set. Don't feel like you have to actually ConvertBack from the converter.
|
|
|
|
|
Thanks for the reply Gideon,
Yes, I have some stuff ready for converting image.
I understand quite, what you are saying here, but still have some doubts.
What I understood:
Should make a class "ByteArrayToImageSourceConverter" and put my stuff inside a method of it.
doubts:
Can you please specify
"Source="{Binding ByteArrayProperty Converter={StaticResource B2IConv}} "
Should "ByteArrayProperty " be a custom property from our new class?
(and if it is, what is it holding? Our Result Byte[] after conversion?
If I am not wrong, we need this property because in WPF any Dependencty property can
accept value from the property of any other object, is that right?)
Is "B2IConv" a method from our class which does the conversion?
What about my Listbox DataContext property? Do I keep it same for getting data in TextBlock?
Sorry, If my questions don't make much sense, as I said am not expert of WPF
|
|
|
|
|
Assuming you are trying to bind imagelisted , ByteArrayProperty will be on whatever object you are binding the textblockProductId TextBlock to. That property would return the byte array that you will then convert into the image. B2IConv was the key I gave to the converter when it was created in XAML
In WPF, only DependencyProperties can be the targets of bindings, but any property can be the source.
Based on your question, I am assuming that the ListBox and TextBlock are already doing what you want and that your only problem was getting the image to work.
|
|
|
|
|
Hi!
I need to create something like slidebar in the shape of circle. When user clicks on the edge of that circle it needs to fill the edge of that circle with some color. Something like clock so when user clicks on 7 then area (edge of circle) from 12 clock to 7 clock is filled with color blue. Area from 7 to 12 is empty or only line can be seen. Can anyone tell me how can I make such a control in wpf?
|
|
|
|
|
Sounds like a fair bit of work, but it's definitely doable. You want it to fill like a clock ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Not like a clock..just want edge to change color and become thicker..or some other efect. Center of the circle is not filled with any color..it is just transparent.
|
|
|
|
|
OK, but the filled area moves around the circle ? I think there are circular sliders already about on the web, sounds like a good starting point to me.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Yes..filed area represents sound volume for example. When it is 100% then it is full circle and when it is 50% then it is only half of the circle edge filled with color and the other half circle edge is emty or in another color.
|
|
|
|
|
Hi,
I am working on a silverlight project. In this I have a media element in silvelight usercontrol. I am using this user control in MainPage.xaml. In the user control I have a button the media element should be fullscreened and then if I click Escape it should return to its original size.
If anyone have any idea to do this please reply me.
Thanks in advance.
|
|
|
|
|
|
Whenever I call my SSL enabled webservice I get this message:
An error occurred while trying to make a request to URI 'https://XXXX.com/XXXX.svc'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.
This service works with no crossdomain issues without SSL. I followed some online guide to enable SSL, which is to add a few lines in crossdomain policy file:
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*">
<domain uri="http://*"/>
<domain uri="https://*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>
Changing the web.config file:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="SSLEnabled" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="Transport" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="XXXX.Web.XXXX">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service behaviorConfiguration="XXXX.Web.XXXXBehavior" name="XXXX.Web.XXXX">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="SSLEnabled" contract="XXXX.Web.XXXX" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
The host I am working on has multiple domain name so I had to add the following code in the WCF service:
Public Class XXXXHostFactory
Inherits ServiceHostFactory
Public Overrides Function CreateServiceHost(ByVal constructorString As String, ByVal baseAddresses() As System.Uri) As System.ServiceModel.ServiceHostBase
Return MyBase.CreateServiceHost(constructorString, baseAddresses)
End Function
Protected Overrides Function CreateServiceHost(ByVal serviceType As System.Type, ByVal baseAddresses() As System.Uri) As System.ServiceModel.ServiceHost
Dim webServiceAddress = New Uri("https://XXXX.com/XXXX.svc")
Dim webServiceHost = New MyServiceHost(serviceType, webServiceAddress)
Return webServiceHost
End Function
Public Class MyServiceHost
Inherits ServiceHost
Public Sub New(ByVal serviceType As Type, ByVal baseAddresses As Uri)
Dim BaseAddressScheme As New UriSchemeKeyedCollection
BaseAddressScheme.Add(baseAddresses)
MyBase.InitializeDescription(serviceType, BaseAddressScheme)
End Sub
Protected Overrides Sub ApplyConfiguration()
MyBase.ApplyConfiguration()
End Sub
Protected Overrides Sub InitializeRuntime()
MyBase.InitializeRuntime()
End Sub
End Class
End Class
And change the markup of the WCF to:
<%@ ServiceHost Language="VB" Debug="true" Service="XXXX.Web.XXXX" Factory="XXXX.Web.XXXXHostFactory" CodeBehind="XXXX.svc.vb" %>
Everything works perfect without SSL, but I added another service for authentication - which requires SSL and made the changes to the code shown above, and I get the crossdomain error.
What else did I miss?
|
|
|
|
|
Hi there,
I was getting the same message with an SSL enabled service recently. It turned out that the name on the certificate in IIS was slightly different than what I had in the WCF binding (I was missing a "companyname.co.nz" on my binding). It didn't really matter without SSL because it was all running locally so the machine-name (without the "companyname.co.nz") was enough.
Something for you to double check anyway.
Cheers.
|
|
|
|
|
Thank you, it turns out everything was set up fine, but the Certificate itself was wrong. The host has fixed it and now the SSL service work fine.
|
|
|
|
|
Also, if you're hosting on IIS, make sure there's an HTTPS binding on the site.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OK, here is the scenario. Take a selector (any type of list item that you can select values) and bind it to an observable collection. Let's say that collection is populated from a service call.
The issue is that you bind, the collection is empty, so there is no selected index. You cannot plug into the Loaded event on the box because if you try to set selectedindex = 0, and the collection hasn't loaded yet, you're out of luck.
In the code behind I can wire into the collectionchanged and then set selectedindex = 0 but that seems a little contrived.
I have a full solution using attached properties but it seems overly complicated for the behavior (I want to always default to the first item in a collection when the collection becomes available).
Anyone have a similiar scenario and thoughts about a solution?
One thing I looked at was having the view model raise a "collection loaded" event, but then again the view will have to hook into that in the code behind.
My attached properties solution basically creates a list of weak references between the selectors and the collections, then hooks into the collection changed event. When it fires, it finds the selector it is linked to and then sets the selected index. It works like a charm but I want to make sure I'm not overcomplicating it when there may be some setting that says, "Default to the first item" when a collection gets filled.
Thanks,
Jeremy
|
|
|
|
|
Hi Jeremy,
One way could be to have a property in the ViewModel like this:
private int _selectedIndex = -1;
public int SelectedIndex
{
get { return _selectedIndex; }
set
{
if (value != _selectedIndex)
{
_selectedIndex = value;
NotifyPropertyChanged("SelectedIndex");
}
}
}
It's set to -1 initially so the XAML doesn't throw an error when there's no collection to bind to.
Bind it to the list box:
<ListBox ItemsSource="{Binding Employees}" SelectedIndex="{Binding SelectedIndex}" />
Then, in the completed event (when the service returns from the asynchronous call with the data) you can set it to whatever you want.
void svcClient_GetDataCompleted(object sender, EmployeeSvc.GetDataCompletedEventArgs e)
{
Employees = e.Result;
SelectedIndex = 1;
}
Not particularly elegant, but it seems to work.
Cheers.
|
|
|
|
|
My data has many columns but a few rows. I need to “rotate” the display with the DataGrid. I wish the DataGrid could display rows as columns, and columns as rows. Is it possible?
|
|
|
|
|
I don't think the datagrid does any transposing at the moment.
This[^] blog post shows a way of transposing your data instead.
Hope that helps.
|
|
|
|
|
hi friends,
i am using a datagrid for my application, i have a combos box in which i am populating data frm a class ie i am using cellEditingTemplate <combobox itemsource="{Binding" theclassname.listused}="" selecteditem="ListUseddataId"> etc i am not able to populate data in the combobox.. how can i debug a combodox data if it is used as data template?
Thanks in Advance...
Regards
Samir
|
|
|
|
|
VCsamir wrote: i am not able to populate data in the combobox
How are you trying to populate the combobox?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I m working on a windows project . i m new in WPF. so my question is can we use wpf controls and graphics in my existing windows project....tell me sum link for tutorial to if this is possible
|
|
|
|
|
Do you mean that you want to host WPF controls inside a WinForms application? Why not write the whole application in WPF?
If you do mean hosting inside WinForms, you might want to follow the tutorial here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|