|
A game algorithm in a Silverlight app.
|
|
|
|
|
Hello All,
I have issue with WCF ASYNC call. WCF service give me a random response. Sometimes it gives me result and sometimes not. I have set max values for binding related properties.
Can anyone can help me to figure out this issue?
Thanks
|
|
|
|
|
This could be something to do with the timeout or buffer size.
Try changing these settings.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Hi,
I wouold like to learn a little about how to design better UI in silverlight or WPF in visual studio.
1-
Is there a book to teach me that in visual studio xaml or should I buy a step by step book in expressin blend? I say expression blend because it seems that I can use the code in expression blend and paste the xaml into visual studio.
Thank you
|
|
|
|
|
I don't know a book to recommend, but you don't need to paste code into visual studio. Expression Blend works with Visual Studio solutions/projects so you can edit (and run) code in Blend and edit and debug in Visual Studio as well.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
To learn better design, Expression Blend would be a better bet than Visual Studio.
As already pointed out, you can edit xaml in Expression Blend as well.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
Yes "Good Answer". You can use Expression Blend to create the UI styles very easily which is very very difficult if you are using Visual Studio to design. Visual Studio requires depth knowledge on XAML. Also more effort is require if you are designing using the VS. Use Expression Blend which will help you a lot.
Silverlight 5 Tutorials : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
|
|
|
|
|
You're welcome and that's what we're here for - to help!
|
|
|
|
|
Hey all,
I'm running into a problem when binding a property of a GroupItemTemplate (in the WP7 LongListSelector) to a converter I built. I want the converter to check if there are items to be displayed in the group, and according to if there are items, set a Brush to the background.
This is my code for the Converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is Group<TrackInfo>)
{
Group<TrackInfo> group = value as Group<TrackInfo>;
if (group != null)
{
if (group.Items.Count == 0)
return (SolidColorBrush)Application.Current.Resources["PhoneChromeBrush"];
else
return (SolidColorBrush)Application.Current.Resources["PhoneAccentBrush"];
}
}
return new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
}
And this is in my XAML:
<DataTemplate x:Key="groupItemTemplate">
<Border Width="99" Height="99" Background="{Binding Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
<TextBlock Text="{Binding GroupTitle}"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="36"
Margin="{StaticResource PhoneTouchTargetOverhang}"
Foreground="{StaticResource PhoneForegroundBrush}"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
<valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />
...
<toolkit:LongListSelector x:Name="lstTracks" Height="800" Width="480" DisplayAllGroups="True"
ListHeaderTemplate="{StaticResource listHeader}"
ListFooterTemplate="{StaticResource listFooter}"
ItemTemplate="{StaticResource itemTemplate}"
GroupHeaderTemplate="{StaticResource groupHeaderTemplate}"
GroupItemTemplate="{StaticResource groupItemTemplate}">
<toolkit:LongListSelector.GroupItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</toolkit:LongListSelector.GroupItemsPanel>
</toolkit:LongListSelector>
I get an Unspecified Error, wich isn't exactly quite helpful... Is there a better way to find out if the group has items and accordingly set a Brush? Or is there an error in my code I don't see?
Thanks for helping,
MadMatt
|
|
|
|
|
You need to have the converter instance in resources somewhere visible to the datatemplate (just like the other static resources you are binding to) so the StaticResource binding works.
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, July 13, 2011 5:58 PM
|
|
|
|
|
The DataTemplate as well as the Converter are in the
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="groupItemTemplate">
<Border Width="99" Height="99" Background="{Binding Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
<TextBlock Text="{Binding GroupTitle}"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="36"
Margin="{StaticResource PhoneTouchTargetOverhang}"
Foreground="{StaticResource PhoneForegroundBrush}"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
<valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />
</phone:PhoneApplicationPage.Resources>
Is there something wrong in here?
|
|
|
|
|
_Madmatt wrote: Background="{Binding Converter={StaticResource groupItemBackgroundBrush}}"
The problem here is that you haven't told the converter what it should bind to. Try changing this to be
"{Binding Path=., Converter={StaticResource groupItemBackgroundBrush}}"
|
|
|
|
|
No, still getting the exception with this setting... 
|
|
|
|
|
Put a breakpoint in your converter and see if it gets hit. Then step over the code to see what breaks.
|
|
|
|
|
It's not even hitting the converter!
Not with this XAML:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="groupItemTemplate">
<Border Width="99" Height="99" Background="{Binding Path=., Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
<TextBlock Text="{Binding GroupTitle}"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="36"
Margin="{StaticResource PhoneTouchTargetOverhang}"
Foreground="{StaticResource PhoneForegroundBrush}"
VerticalAlignment="Bottom"/>
<Border.Resources>
<valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />
</Border.Resources>
</Border>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
And not with this one too:
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="groupItemTemplate"
<Border Width="99" Height="99" Background="{Binding Path=., Converter={StaticResource groupItemBackgroundBrush}}" Margin="6" IsHitTestVisible="{Binding HasItems}">
<TextBlock Text="{Binding GroupTitle}"
FontFamily="{StaticResource PhoneFontFamilySemiBold}"
FontSize="36"
Margin="{StaticResource PhoneTouchTargetOverhang}"
Foreground="{StaticResource PhoneForegroundBrush}"
VerticalAlignment="Bottom"/>
</Border>
</DataTemplate>
<valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />
</phone:PhoneApplicationPage.Resources>
|
|
|
|
|
Not sure, maybe I'm wrong, but have you tried to put converter definition before your datatemplate?
|
|
|
|
|
Thanks! This did the trick! Too bad I didn't think of that myself... 
|
|
|
|
|
Try by making this line - <valueConverters:TrackGroupToGroupItemBackgroundBrushConverter x:Key="groupItemBackgroundBrush" />; part of the Itemsources or UserControls resource.
|
|
|
|
|
They are both part of the <phone:PhoneApplicationPage.Resources> , I cannot create a <DataTemplate.Resources> , so where should I put it else? This is quite confusing to me, it's the first time is use XAML binding in such a complex way...
Thanks
|
|
|
|
|
I have created simple SL business application. I am trying to learn membership and authentication and configured the following:
1. Install the ASPNETDB
2. Part of the Web.config looks like this
<roleManager enabled="true" />;
<authentication mode="Forms">;
<forms name=".Test_ASPXAUTH" />;
</authentication>>
<profile>
<properties>
<add name="FriendlyName" />
</properties>
</profile>
</system.web>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=TPSA11;Initial Catalog=aspnetdb;Integrated Security=True" />
<add name="TestEntities" connectionString="metadata=res://*/TestModel.csdl|res://*/TestModel.ssdl|res://*/TestModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=TPSA11;Initial Catalog=Test;Persist Security Info=True;User ID=sa;Password=service;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
3. In App.Xamel.cs
InitializeComponent();
WebContext webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
4. The home page contains a datagrid that gets populated but to force authentication I added
[RequiredRole(“ADMIN”)]
Before the query used to populate the datagrid.
When I execute the application within VS2010 (debug mode), the datagrid is empty until a login with credentials with ADMIN role then it gets populated.—so far so god.
But when I run the application outside VS (e.g. http://servername:port/testApp.html the datagrid is loaded by default . If I try to login anyways, I get an error:
“Load operation failed for query “login” “System.ServiceModel.DomainServices.Client.DomianOperation” was thrown”
This is also captured using fiddler:
@_Fault_5http://schemas.microsoft.com/ws/2005/05/envelope/none@_Code@_Value_Sender_@_Reason@_Text__xml_lang_en-US>Login and Logout can only be invoked for Forms authentication._@_Detail@_DomainServiceFault__DomainServices _i)http://www.w3.org/2001/XMLSchema-instance@ ErrorCode_@
ErrorMessage>Login and Logout can only be invoked for Forms authentication.@_IsDomainException@
StackTraceL_ at System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase`1.Login(String userName, String password, Boolean isPersistent, String customData)
at Login(DomainService , Object[] )
at System.ServiceModel.DomainServices.Server.ReflectionDomainServiceDescriptionProvider.ReflectionDomainOperationEntry.Invoke(DomainService domainService, Object[] parameters)
at System.ServiceModel.DomainServices.Server.DomainOperationEntry.Invoke(DomainService domainService, Object[] parameters, Int32& totalCount)
at System.ServiceModel.DomainServices.Server.DomainService.Query(QueryDescription queryDescription, IEnumerable`1& validationErrors, Int32& totalCount)
at System.ServiceModel.DomainServices.Hosting.QueryProcessor.Process[TEntity](DomainService domainService, DomainOperationEntry queryOperation, Object[] parameters, ServiceQuery serviceQuery, IEnumerable`1& validationErrors, Int32& totalCount)
Any help is greatly appreciated
|
|
|
|
|
When you run in the debugger (and it works) what is the service host? IIS? Development server?
It looks like whatever host you are using when the failure occurs isn't configured properly for forms authentication.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
They are different. The connection used when debugging in VS2010 uses a dynamic port (http://servername:58357/MySite/MyFileTest.html)
The actual site is http://mySite/MyFile.html
I have tried:
1. disable all authentication except FORM and anonymous
2. The application pool is configured as Integrated NET 4.0
still error
"Failure using default "membership". Make sure is configured correctly. Login failed for IIS AAPPOOL\MySite
thannX
|
|
|
|
|
 Ok, so hosting in debugger you are using the Visual Studio test server and the other is on IIS, correct (what server host you are using is important!)?
If the above is correct then you haven't configured IIS correctly. The authorization and role manager need to be setup. If you're using SQL Server (Express is fine) to store user/role info then that needs to be configured for your app if you haven't done so already. There's a Aspnet_regsql.exe utility to do it for you.
Then you need to configure the manager(s) to use your database by supplying a connection string. IIS uses "LocalSqlServer" by default so you should have that covered as long as your "LocalSqlServer" connection string connects to a valid IIS/ASP.NET configured database.
For what it's worth, here's an example of one of my configurations...note I do NOT use the default connection string name here so I have to specify the connection string for each provider...
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http:
-->
<configuration>
<appSettings>
</appSettings>
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="MyConnectionString" connectionString="Data Source=localhost;Initial Catalog=myCatalog;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authorization>
<!--
<deny users="?" />
-->
<allow users="*" />
</authorization>
<authentication mode="Forms" >
<forms name="MyFormsName" timeout="30" />
</authentication>
<membership defaultProvider="TheSqlMembershipProvider"
hashAlgorithmType=""
userIsOnlineTimeWindow="15" >
<providers>
<clear/>
<add name="TheSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="MyConnectionString"
applicationName="/"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="10"
minRequiredNonalphanumericCharacters="1"
minRequiredPasswordLength="7"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<roleManager enabled="true"
defaultProvider="TheSqlRoleProvider"
cacheRolesInCookie="false"
cookieName=".ASPXROLES"
cookiePath="/"
cookieProtection="All"
cookieRequireSSL="false"
cookieSlidingExpiration="true"
cookieTimeout="30"
createPersistentCookie="false"
domain=""
maxCachedResults="25" >
<providers>
<clear />
<add name="TheSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="MyConnectionString"
applicationName="/" />
</providers>
</roleManager>
<profile enabled="true"
defaultProvider="TheSqlProfileProvider"
automaticSaveEnabled="true" >
<providers>
<clear />
<add name="TheSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="MyConnectionString"
applicationName="/" />
</providers>
<properties>
<add name="FriendlyName"/>
<add name="ZipCode" />
<add name="CityAndState" />
</properties>
</profile>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|