|
As Lloyd has indicated, the easy way to do this is to place your image on the form first, and then place a TextBlock on the form as well. Use the margin property to change the position of the text.
"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
|
|
|
|
|
Hi,
I can not create a silverlight project in visual studio 2008 .net 3.5, sp1.
In add remover programs I can see the Microsoft silverlight version 3 is installed.
I have also installed Microsoft Tools Alpha Refresh for visual studio 2008.
On trying to create a silverlight project in visual studio, the error message is:
"The project type is not supported by this installation"
Any thoughts please?
Thanks
|
|
|
|
|
Does that[^] helps?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
|
Silverlight required VS2008 SP1, which I believe is already installed. Secondly you need to install Silverlight SDK 3.0 and Silverlight Toolkit.
Installing these packets will solve your problem.
|
|
|
|
|
|
Hi All,
I have one image control, Currently I am setting the image path as absolute. Since the image is at the server side where the Silverlight application is hosted.The source set as follows:
<Image x:Name="imgMyImage" Source="http://localhost/MyImage.JPG" >
I want to set the relative source from the server in the style.
I followed following link and I succeed giving the relative path from the Image tag itself.
http://wildermuth.com/2008/03/31/Silverlight_2_Bugs_and_Issues.aspx
<Style x:Key="MyImageSetter" TargetType="Image">
<Setter Property="Source" Value="MyImage.JPG"></Setter>
</Style>
But how can I do this with style? Something like this:
When I set with this way it gives me image error
|
|
|
|
|
Your post is messed up so I can't see what you may have done wrong.
URIs for resource files are described here:
Resource Files[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
1.
Build Action of Image = Resource
2.
<UserControl x:Class="SilverlightApplication3.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns ="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<UserControl.Resources>
<Style x:Key="MyImageSetter" TargetType="Image">
<Setter Property="Source" Value="Al Pascual.jpg" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<Image Style="{StaticResource MyImageSetter}" />
</Grid>
</UserControl>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
Microsoft MVP (Silverlight), WPF/Silverlight Insiders
|
|
|
|
|
Hi,
I am working on a silverlight application which deals with RSS feeds. As we cannot directly access RSS feeds of all the websites I wrote a WCF service to get the RSS feeds and then I passed them to the silverlight application.
In this application I have to get the Title, description and Navigation link of each item in the feed. In description I am getting all the Html content in it for description. But I have to get only the text in the description.
I tried to get it like this
rssReader = new XmlTextReader(FeedURL);
SyndicationFeed feed = SyndicationFeed.Load(rssReader);
List<SyndicationItem> feedItems = new List<SyndicationItem>();
foreach (SyndicationItem feedItem in feed.Items)
{
feedItems.Add(feedItem);
}
But for this I am getting error at line:2 as:
The type 'System.Xml.XmlReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
I tried to add System.Xml of Version=2.0.5.0 but I cannot find it in the reference.
If anyone have idea to solve this error or procedure to get only the text in the description node please reply me.
Thanks in advance.
|
|
|
|
|
|
Below is the code page:
public partial class DataBinding : UserControl
{
public DataBinding()
{
InitializeComponent();
List<PlaylistItem> lstPLI = new List<PlaylistItem>();
for (int i = 0; i < 3; i++)
{
lstPLI.Add(new PlaylistItem("Name" + i.ToString(), "Path" + i.ToString()));
}
lstPlayList.ItemsSource = lstPLI;
}
}
public class PlaylistItem
{
public string FileName;
public string FilePath;
public PlaylistItem()
{
}
public PlaylistItem(string filename,string filepath)
{
FileName = filename;
FilePath = filepath;
}
}
And here is the xaml page:
<UserControl x:Class="FirstSilverLight.DataBinding"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<ListBox x:Name="lstPlayList">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding FileName}"></TextBlock>
<TextBlock Text="{Binding FilePath}"></TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</UserControl>
The Listbox doesnot show any items in it when I run this, though Listbox items.count is 3 when i debug this. Any idea what the problem is?
s.a.w.
|
|
|
|
|
Make the strings properties instead of fields:
public string FileName { get; set; }
public string FilePath { get; set; }
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
WOW! that solved my problem.
But what i'm still wondering is I have a similar class called 'DirInfo' in my webservice with two string fields(NOT string properties). And when i get List<DirInfo> as return object from its webmethod, I bind it directly to another ListBox. Here it works perfectly without any string properties.
Any idea why this could be?
(FYI: when List<DirInfo> is returned in the <WebMethodeCompletedHandler> its returned in e.Results as System.Collections.ObjectModel.ObservableCollection<DirInfo> object.
Is this anyway related to my question?
)
Thanx again for the help.
s.a.w.
|
|
|
|
|
sunit_82 wrote: when i get List<dirinfo> as return object from its webmethod, I bind it directly to another ListBox. Here it works perfectly without any string properties.
Any idea why this could be?
I can't get that to work.
What does your DirInfo class look like on the client side? Did the proxy class
creation process convert fields to properties?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
<ListBox x:Name="lstPlayList", ItemsSource="{Binding ListName, Mode="TwoWay"}">
|
|
|
|
|
Ok ..i built a simple custom control. A tranparent button. Some of you may have seen it.
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="GlassButton"
x:Name="GlassButton" Width="100" Height="30">
<UserControl.Resources>
<ControlTemplate x:Key="GlassButton" TargetType="{x:Type Button}">
<Grid x:Name="OuterGird">
<Rectangle Margin="0,0,0,0" VerticalAlignment="Stretch" StrokeThickness="1" RadiusX="4" RadiusY="4">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.369,0.21" StartPoint="0.675,0.774">
<GradientStop Color="#9992C0E8" Offset="0"/>
<GradientStop Color="#FF1E86DC" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Fill>
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.382,0.116" StartPoint="0.618,0.884">
<GradientStop Color="#FF2511D8" Offset="0"/>
<GradientStop Color="#FFABCCE8" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
<TextBox Margin="0,0,0,0" Text="{TemplateBinding Content}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0,0,0,0" Foreground="#FFFFFFFF" Background="#00FFFFFF" x:Name="ButtonTextBox"/>
<Path Stroke="{x:Null}" Margin="8,3.712,5.029,8.122" Stretch="Fill" StrokeThickness="0" Data="M167.80889,10.198788 C168.06227,8.3587256 167.20925,7.2831486 165.45782,6.9550772 L19.671443,7.637693 C18.742518,7.708315 15.582248,7.6193257 15.429944,7.5239237 15.429944,7.5239237 12.279116,7.979001 12.279116,7.979001 11.119595,8.2070631 10.356582,9.1665193 9.9996476,10.875024 9.9996476,10.875024 9.8747544,13 9.8747544,13 L9.8557733,52.576677 C10.339993,53.918511 11.067782,54.510987 11.915916,55.079524 12.76405,55.648062 14.503288,55.148249 16.548011,54.66758 18.263785,47.574348 165.59877,4.0491713 167.80889,10.198788 z">
<Path.Fill>
<LinearGradientBrush EndPoint="0.513,1.002" StartPoint="0.517,-0.105">
<GradientStop Color="#B2FFFFFF" Offset="0"/>
<GradientStop Color="#19FFFFFF" Offset="1"/>
<GradientStop Color="#77FFFFFF" Offset="0.382"/>
<GradientStop Color="#33FFFFFF" Offset="0.658"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Height="Auto" Width="Auto">
<Button HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto" Content="what" Template="{DynamicResource GlassButton}" Background="#FFD4D0C8" x:Name="BaseButton" BorderThickness="0,0,0,0" />
</Grid>
</UserControl>
I want anyone who uses this control in their WPF project to be able to modify 3 properties on it
a) button text,
B) Button colour and
C) the degree of opacity.
Here in lies the problem i have read that you cannot change the values of a controltemplate. As you can see from the xaml above even the text normally found ontop of a button is held in a textblock deep inside the controltemplate.
Can some one show me how to expose these three properties of the control to a calling program
regards
Erick
|
|
|
|
|
Create a new style, and assigned your template:
<style TargetType="Button">
<Setter Property="Template" Value="{StaticResource GlassButton}" />
</Style>
That should allow you to change your buttons styles i the actual button definitions.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
With a UserControl implementation like that you can expose regular properties to the
user from your UserControl-derived class and bind to those properties in the control's
XAML.
Simple example (important changes marked in red):
public partial class GlassButton : UserControl
{
<code>public string ButtonContent { get; set; }
public Brush ButtonFill { get; set; }</code>
public GlassButton()
{
InitializeComponent();
<code>this.DataContext = this;</code>
}
}
<UserControl x:Class="WPFTester.GlassButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<UserControl.Resources>
<ControlTemplate x:Key="GlassButton" TargetType="{x:Type Button}">
<Grid x:Name="OuterGird">
<Rectangle Margin="0,0,0,0" VerticalAlignment="Stretch" StrokeThickness="1" RadiusX="4" RadiusY="4" <code>Fill="{Binding ButtonFill}"</code>>
<Rectangle.Stroke>
<LinearGradientBrush EndPoint="0.382,0.116" StartPoint="0.618,0.884">
<GradientStop Color="#FF2511D8" Offset="0"/>
<GradientStop Color="#FFABCCE8" Offset="1"/>
</LinearGradientBrush>
</Rectangle.Stroke>
</Rectangle>
<TextBox Margin="0,0,0,0" Text="{TemplateBinding Content}" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Center" BorderThickness="0,0,0,0" Foreground="#FFFFFFFF" Background="#00FFFFFF" x:Name="ButtonTextBox"/>
<Path Stroke="{x:Null}" Margin="8,3.712,5.029,8.122" Stretch="Fill" StrokeThickness="0" Data="M167.80889,10.198788 C168.06227,8.3587256 167.20925,7.2831486 165.45782,6.9550772 L19.671443,7.637693 C18.742518,7.708315 15.582248,7.6193257 15.429944,7.5239237 15.429944,7.5239237 12.279116,7.979001 12.279116,7.979001 11.119595,8.2070631 10.356582,9.1665193 9.9996476,10.875024 9.9996476,10.875024 9.8747544,13 9.8747544,13 L9.8557733,52.576677 C10.339993,53.918511 11.067782,54.510987 11.915916,55.079524 12.76405,55.648062 14.503288,55.148249 16.548011,54.66758 18.263785,47.574348 165.59877,4.0491713 167.80889,10.198788 z">
<Path.Fill>
<LinearGradientBrush EndPoint="0.513,1.002" StartPoint="0.517,-0.105">
<GradientStop Color="#B2FFFFFF" Offset="0"/>
<GradientStop Color="#19FFFFFF" Offset="1"/>
<GradientStop Color="#77FFFFFF" Offset="0.382"/>
<GradientStop Color="#33FFFFFF" Offset="0.658"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</Grid>
</ControlTemplate>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Height="Auto" Width="Auto">
<Button HorizontalAlignment="Stretch" Margin="0,0,0,0" VerticalAlignment="Stretch" Width="Auto" Height="Auto" <code>Content="{Binding ButtonContent}"</code> Template="{DynamicResource GlassButton}" x:Name="BaseButton" BorderThickness="0,0,0,0" />
</Grid>
</UserControl>
Sample usage:
<local:GlassButton ButtonContent="Hey!" >
<local:GlassButton.ButtonFill>
<LinearGradientBrush EndPoint="0.369,0.21" StartPoint="0.675,0.774">
<GradientStop Color="#9992C0E8" Offset="0"/>
<GradientStop Color="#FFFF0000" Offset="1"/>
</LinearGradientBrush>
</local:GlassButton.ButtonFill>
</local:GlassButton>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
There's a strange behaviour when using WPF in windows vista:
i want my menu items to be White on the MainMenu of my application, while the children remain regular color.
So i set the Foreground property to white (on the top level)
in vista the child menu items inherit this foreground (!)
I found a reference to it here:
http://journals.tuxreports.com/lch/archives/004031.html[^]
Does any have a solution for that?
Note: when setting all the other item to "Black", i use the feature of opposite color when selecetd, and i don't want to implement it by myself
Thanks,
Yanai
|
|
|
|
|
I think it's a feature.
WPF has theming capabilities and use different default themes on different OSes.
To play with themes, have a look there[^]
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Hi and thanks
But i don't understand how is it a feature? and how is the themes gonna help me.
as remembered, all i want to do is color the foreground color of my menu items in white, while the rest will stay default.
and for it to work in XP\Vista\Windows 7
And i can't
does anybody have a solution to that?
Thanks again
|
|
|
|
|
It's the way the menu behave!
How is it done and different depending on the platform in WPF?
Well, WPF ship with a few build-in theme. Aero is the vista look, Luna is the XP look (if I'm right).
Then the theming capabilities of WPF choose the appropriate default look for the OS.
If you want your menu to look always the same you got to either of:
1. fix the theme so that it doesn't change with the OS
2. or simply set up a MenuItem style in your App.config.
Fix the theme will ensure that your app looks the same whatever the UI and will get you a deeper understanding of what's going on. (As writing a them is huge undertaking, better re-us an existing one).
Write a custom MenuItem style is a less general solution (it will only make the menu similar, but the you'll got the same problem for scrollbar, button, combobox, etc.....)
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Ok now i see what you mean
I've set my project to work with Luna (XP) only (in the App Resource)
Unfortunatley, it doesn't solve the problem...
|
|
|
|
|
Hi
I get very poor performance when rotating or moving 3d models. At first I thought it might be the TrackBall from the 3DTools library, so I reverted back to using sliders, but I was still getting poor performance. The models lag when rotating and it gets pretty irritating. Also, I'm reading dimensions out of an Access database and then use these dimensions to construct the 3D models, so it might be because of this? I'm only using one connection string.
Is my application staying connected to the database the whole time? Do I need to disconnect somehow?
|
|
|
|
|