|
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++
|
|
|
|
|
|
So each version of Silverlight that comes out I take a look and see how the technology is progressing. I finally got to SL4. This may be user error but I'm really frustrated with the data access. I first tried POCO, using my own objects from the server. Got those passed through WCF and bound but then you can't use the DataAnnotations (I like the ID of having the validations for the data where the data lives in the class) when you bind on the client. Then I went to the WFC Data Service model using MVVM. Looked good but then guess what, same issue. Lastly I went to RIA but couldn't figure out how to add an object on the client. Evidently MS didn't build my Insert function on the Domain Service. So I went to go look for myself. So many generated functions with odd attributes my eyes hurt. I’ve looked at videos which all simply just edit objects but don’t add anything. But if they would I can get the DataAnnotations working with RIA but I have to do this kludgy Metadata object.
So is there a better way or am I doing something wrong? I hate MS generated black boxes because they tend not to work for real applications and then when something does go bump in them you spend hours on google researching only to find out you are so in bed with them you have to wait till next release to get it fixed. I’m just about to create my own Data layer architecture for working with SL but before I do I thought I would do a sanity check with the guru’s. What did I miss? Is there a better way?
|
|
|
|
|
WCF RIA Services will give you the most RAD help with dataannotations.
The metadata object may seem kludgy but it's not so bad. The code it is decorating is Visual Studio generated code that you shouldn't edit anyway so it doesn't really make a difference because you're not editing same code in more than one place.
You're still responsible for adding CRUD operations to the service yourself, so if the default generated code doesn't include an insert method then you simply add one yourself. Generally you'll end up adding lots of variations on insert, delete, and add service methods.
And there's no black box here. All the generated code is part of your project.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
There never was a chance that we would use RIA, for the same reasons you iterate, black box, MS defined and constrained functionality etc. We built our own, first building a code generator (modified the existing one which began life in VB5) to service the WCF requirements. This is basically simple boilerplate code for the object and CRUD work.
This pushes 90% of our work into the VM and View, where we have some really cool snippets that eliminate all the donkey work and leaves us with the difficult stuff like making the dammed view do as it is told!
It is painful getting a design idea wrong, you should see the crap we (I) created around dialog management before I got a handle on the child window concept.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am looking to use the shape functionality in WPF in order to apply two triangles one pointing up and the other pointing down along with the plus sign to some buttons. Having a look there doesn't seem to be an easy to do this. Does anyone have an example where this can be easily done?
Thank
|
|
|
|
|
Check out the Path class. Triangles and plus signs are easy
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
An easier way is to use an appropriate font. Triangles are just "y" in Wingdings 3.
|
|
|
|
|
Yes, for WPF apps one can use the Font but if he wants to use it for Silverlight, he has to create the shape using Path control.
Silverlight 5 Tutorials : 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
|
|
|
Member 2972992 wrote: two triangles one pointing up and the other pointing down along with the plus sign
It will be easier is you have Expression Blend Installed,the pen tool allow you to draw shape and you can convert a plus in text format to shape
|
|
|
|
|
If I have:
Dictionary<string, Dictionary<int, TestStruct>> _dict = new Dictionary<string, Dictionary<int, TestStruct>>();
and want the top level nodes to be bound to Key and the underneath nodes to be bound to Value.Name (from TestStruct), I have the following HierarchialDataTemplates:
<HierarchicalDataTemplate x:Key="TopLevelTemplate" ItemsSource="{Binding Value}">
<TextBlock Text="{Binding Path=Key}" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="SecondLevelTemplate">
<TextBlock Text="{Binding Path=Value.Name}" />
</HierarchicalDataTemplate>
I got it to work with a data template selector like this:
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
FrameworkElement element = container as FrameworkElement;
System.Type t = typeof(System.Collections.Generic.KeyValuePair<int, TestStruct>);
if (item.GetType() == t)
return element.FindResource("SecondLevelTemplate") as DataTemplate;
return element.FindResource("TopLevelTemplate") as DataTemplate;
}
but that kind of seems hacky... is there a way to get generics going in the HierarchialDataTemplates?
I know the usual solution is to do something like:
public class ItemCollection : List<TestStruct>
and use ItemCollection everywhere, but that doesn't really work with Dictionaries, since you are still getting KeyValuePair(K, V) from the enumerator.
|
|
|
|
|
Good Day All
i have placed a CrossDomain and the ClientPolicy Files in the Root of the IIS directory wwwroot.
We are currently having a problem on our side, our Network administrator says he has opened port 80 , but those policy files are not accessible from outside.
i change the port of my site to 8081 and the site is fine, but it needs to policy files that are accessible through port 80.
i goolged a bit and i see some people trying to programatically change the address location of the policy file.
You see the policy files that i can access , i can access them if i entered the port, and IIS looks for the policy Files in the Root Directory and those are accessible with port 80.
There are two things that i can settle for.
1) Its either the port 80 issue is resolved
2) The Policy files should be accessible via the new port.
I used Fidler to inspect this and i have the results in the attachment
http://www.tiyaneproperties.co.za/FidlerResults.png[^]
I need advice.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
The port number is part of the domain and the client should be requesting the policy file at the same domain as the connection attempt. Are you sure it's requesting the file on port 80 or have you not configured the client to connect to the new port?
And why isn't the policy file accessible from outside on port 80?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi Mark it was accessing it on port 80, we have installed a new Server and now it is working, there was something that was blocking it.
thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
How to hide/remove a wpf system tray application from alt+tab dialog?
- Regards - J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers
|
|
|
|
|
Setting the main window Visibility = System.Windows.Visibility.Hidden hides it for me on Windows 7.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|