|
Hey y'all has anyone else run across this problem? and if so is there a work around?
I have a ResourceDictioinary where I have a linear brush declared;
<LinearGradientBrush x:Key="BlueLinearBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<gradientstop color="PowderBlue" offset="0" />
<gradientstop color="SteelBlue" offset="1" />
</LinearGradientBrush>
and a style that uses the Brush
<style x:key="CustomBorderStyle" targettype="{x:Type Border}">
<setter property="Background" value="{StaticResource BlueLinearBrush}" />
.....
</style>
In my App.xaml file I have cone the MergeDictioinaires
then in my code I use it:
.....
<border horizontalalignment="Stretch">Style="{StaticResource CustomBorderStyle}">
<textblock text="{Binding Path=Name}" horizontalalignment="Center" fontweight="Bold" />
</border>
.....
but it gives me problems here?
I've googled and the examples I've found say this is legal as seen here[^]. The app runs fine but its annoying because I can't see the design or look at properties because of the error.
WTF?
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
modified on Sunday, March 15, 2009 8:26 PM
|
|
|
|
|
Mike Hankey wrote: WTF?
No. That's "WPF"
I plugged your brush and style code in without using merged dictionaries (just put
it in the Application.Resources). Aside from the typo:
<border horizontalalignment="Stretch"> Style="{StaticResource CustomBorderStyle}">
which should be:
<border horizontalalignment="Stretch" Style="{StaticResource CustomBorderStyle}">
it worked fine.
What's the error?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for your input Mark. See the response I gave to Pete.
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
Mike - what error do you get? Apart from the invalid markup here horizontalalignment="Stretch">;Style="{StaticResource CustomBorderStyle}", this all looks perfectly legal (assuming, of course, that you have just made a mistake typing your markup in here because XAML is case sensitive, so textbox is not the same as TextBox).
"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
modified on Monday, March 16, 2009 4:52 AM
|
|
|
|
|
Thanks for your input Pete,
Pete O'Hanlon wrote: horizontalalignment="Stretch">;Style="{StaticResource CustomBorderStyle}"
I'm a terrible typer...I was going back and adding the < and > 's and produced the typo.
I get these error periodically when working with UserControls, which is where the style is used and I get 3 errors.
Could not create instance of ProjectView (my user control)
Value TaskMgrResourceDictionary.xaml cannot be assigned to property 'Source'. The resource dictionary XAML file has errors and cannot be loaded.
The application XAML file failed to load. Fix errors in the application XAML before opening the XAML files.
Like you if I strip this code out and and use it in line it works great. Its in several locations also, and all are user controls? Except for the MainWindow not showing because of the errors in the user controls.
Thanks,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
Mike Hankey wrote: Value TaskMgrResourceDictionary.xaml cannot be assigned to property 'Source'. The resource dictionary XAML file has errors and cannot be loaded.
Since it works inline, your problem seems to be in the resources, as
indicated by the errors. That's probably a good place to look for errors
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark,
I had this problem using a DataGrid control and turned out that I could remove the code that styled the headers and it worked for a while then quit again a short time later. I'm thinking it has something to do with UserControls but not quite sure. The reason I posted this question was to see if anyone else had had this problem using UserControls in their app. I've heard that there are problems using them and was wanting to see if this was one of them.
Thanks,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
I use UserControls extensively and I've never had any problems with them. The only thing I can think of is that you might have a problem with the way they have been registered when you have merged your ResourceDictionaries.
"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
|
|
|
|
|
Operator error, surely not.
This is my app.xaml file.
<Application x:Class="WpfTaskManager.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="TaskMgrResourceDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Appreciate the input. You've convinced me that I am the cause of the problem so will get with the program and find it. Didn't want to pull my hair out over this one, (as I get older and my hair thinner I have to be careful of the problems involving hair pulling. , if it wasn't something that I had done.
Thanks,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
Mike,
Ditto Pete's reply - If UserControls had a major malfunction I'd be in a
world of pain and tears
I still suspect the culprit is in the bowels of your TaskMgrResourceDictionary.xaml.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks guys,
You are probably right, its got to be somewhere in there and will remove code until I find it.
I'm just getting my sleaves rolled up with WPF and am bound to make many stupid mistakes. Hope y'all will bear with me. I can get most of them without help but sometimes I just plain get frustrated and need a shove, or a shift kick in the kester.
Thanks again,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
Mike - I've got to recommend Blend as an invaluable help here. It allows you to save resources, which you set through the interface, removing chances for errors.
"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
|
|
|
|
|
Pete O'Hanlon wrote: I've got to recommend Blend as an invaluable help here
Pete,
You are probably right but there are/were two things that held me back from purchasing;
1) I'm just to damn cheap to buy it, can't justify the $500
2) I looked at like this. It's like driving a car, if you learn to drive a stick you can drive anything on the road, if you learn automatic your limited. Don't know if this makes any sense or not?
I've got a trial version of blend but really haven't taken the time that I should with it. Boss at work gave us an assignment to do an Outlook demo and I thought it was pretty cool, had some quirks but it was probably just me.
I'll give blend another try.
Thanks,
Mike
"It doesn't matter how big a ranch ya' own, or how many cows ya' brand, the size of your funeral is still gonna depend on the weather." -Harry Truman.
Semper Fi
http://www.hq4thmarinescomm.com[ ^]
My Site
|
|
|
|
|
Mike Hankey wrote: if you learn to drive a stick you can drive anything on the road, if you learn automatic your limited. Don't know if this makes any sense or not?
I'm from the UK. That's pretty much the only way to learn over here. If you learn automatic over here, you're not qualified to drive stick.
"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
|
|
|
|
|
Use DynamicResource because the resource is defined in an external file and will not be resolved until runtime.
|
|
|
|
|
|
Cool! Thanks for the update!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
No problem fella. I haven't installed it myself yet as I have too many deadlines at the mo to risk any problems. Have you gone for it yet?
Cheers,
|
|
|
|
|
Jammer wrote: Have you gone for it yet?
Applied hotfix late last night, working with XAML today...we'll see...
it may take a while to realize it's crashing less, since I never had a
reproduceable case.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Gotcha. Pre SP1 I was seeing at least a couple of crashes a day with with XAML so it's interesting to see this appear now.
|
|
|
|
|
Can anyone help me in letting me know how to bind a dataset to a listbox in a WPF XBAP application.
The dataset contains a table with two columns.
-----Have A Nice Day-----
|
|
|
|
|
You bind the DataContext of the ListBox to the DataSet and set the ItemsSouce binding with Path as the tablename
OR you directly bind the table to the ItemsSource property.
|
|
|
|
|
Hi,
Can you please provide me the code to set the ItemSource binding to the path as suggested by you.
-----Have A Nice Day-----
|
|
|
|
|
1. Setting the DataSet to the DataContext and binding the ItemsSource using binding Path.
e.g.,
In code setting the DataContext,
yourListBox.DataContext= yourDataSet;
in XAML setting ItemsSource binding,
<listbox name="yourListBox" itemssource="{Binding Path=YourTableName}">2. Setting the DataTable directly to the ListBox's ItemsSource,
yourListBox.ItemsSource = yourDataSet.Tables["YourTableName"];
|
|
|
|
|
You bind the DataContext of the ListBox to the DataSet and set the ItemsSouce binding with Path as the tablename
OR you directly bind the table to the ItemsSource property.
dharmesh
|
|
|
|