|
Please take a look at my reply in your previous message http://www.codeproject.com/script/Forums/View.aspx?fid=1004257&msg=2584440[^]
In Silverlight 2 beta1, all default templates for all user controls are stored in generic.xaml. If you are creating custom database which is inherited from build-in control, you will need to use those styles from generic.xaml unless you create all required template by yourself.
|
|
|
|
|
Hi Friends,
I am unable to create docking control in silver light 2.0.My requirement is I am using one menu control in silver light,I want to apply docking to that control.So I am unable to do that,can u pleaes help me in this.
Regards
Kishore
|
|
|
|
|
|
Hi,
I am using visual studio 2008 to code behind my silverlight application(drag and drop). I have been browse ans see the sample from online and silverlight book. But i having the problem here.
When I loaded the silverlight application in asp.net
Page.xaml
<canvas x:name="parentCanvas">
x:Class="SilverlightApplication5.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="parentCanvas_Loaded"
Width="400" Height="300" Background="Aquamarine">
x:Name="submit" Width="100" Height="200" Canvas.Top="100" Background="Azure" >
Page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace SilverlightApplication5
{
public partial class Page : Canvas
{
private void parentCanvas_Loaded(object sender, RoutedEventArgs e)
{
InitializeComponent();
}
}
}
The mozilla browser do not show up any silverlight content,jz blank it where I have plug in the silverlight in asp.net.
When I remove the "LOADED" element from the Page.xaml and use direct InitializeComponent() in Public Page(), it works.
So, what is the problem with this??
Thanks.
Regards,
Katelva
|
|
|
|
|
Please check "Ignore HTML tags in this message" when you are posting XAML, XML or HTML code.
I need to look at the your Page.xaml to find out the error.. Could you please post your XAML code?
|
|
|
|
|
Page.xaml
x:Class="SilverlightApplication5.Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="parentCanvas_Loaded"
Width="400" Height="300" Background="Aquamarine">
<button> x:Name="submit" Width="100" Height="200" Canvas.Top="100" Background="Azure" > </button>
|
|
|
|
|
Hi All,
I'm just working on the Skinning code/xaml and i'm seeing a really odd error:
Cannot convert the value in attribute 'Color' to object of type 'System.Windows.Media.Color'. '#FF323232' is not a valid value for property 'Color'. Error at object 'PassWordBoxBackground.Default' in markup file 'Utils.WPFThemes.Default;component/DefaultTheme_SolidColorBrushes.xaml' Line 74 Position 66.
I was under the impression that a DynamicResource could be fed by another DynamicResource ... am I wrong here or this due to a different problem? I have other instances of a this setup that appear to be working.
<solidcolorbrush x:key="PassWordBoxBackground.Default" color="{DynamicResource AppBackground.Default}" />
Cheers,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi!
I am creating a ControlTemplate for a Button. A button gets it's 3D look with BevelBitmapEffect which is applied to the Canvas which holds the controls that are used in the template. I meant to use the HorizontalContentAlignment and VerticalContentAlignment properties of the button to Rotate the button. I also need to change the LightAngle of the BevelBitmapEffect when the button is rotated. Here is an simplified example:
<ControlTemplate x:Key="ArrowBtnTmp" TargetType="{x:Type ButtonBase}">
<Viewbox Stretch="Uniform">
<Canvas Width="136" Height="52">
<Path Width="135.046" SnapsToDevicePixels="True"
Height="51.862"
Fill="{TemplateBinding Background}"
Stretch="Fill"
Canvas.Left="0"
Canvas.Top="0"
Data="..."/>
<Canvas.BitmapEffect>
<BevelBitmapEffect x:Name="BevelEffect" LightAngle="135" />
</Canvas.BitmapEffect>
<Canvas.RenderTransform>
<RotateTransform x:Name="RotateTransform" Angle="0" />
</Canvas.RenderTransform>
</Canvas>
</Viewbox>
<ControlTemplate.Triggers>
<Trigger Property="HorizontalContentAlignment" Value="Right">
<Setter TargetName="BevelEffect" Property="LightAngle" Value="225" />
<Setter TargetName="RotateTransform" Property="Angle" Value="90" />
</Trigger>
<Trigger Property="VerticalContentAlignment" Value="Bottom">
<Setter TargetName="BevelEffect" Property="LightAngle" Value="315" />
<Setter TargetName="RotateTransform" Property="Angle" Value="180" />
</Trigger>
<Trigger Property="HorizontalContentAlignment" Value="Left">
<Setter TargetName="BevelEffect" Property="LightAngle" Value="45" />
<Setter TargetName="RotateTransform" Property="Angle" Value="270" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
But the example does not work. I get a compile error saying:
Cannot find the trigger target BevelEffect.
Am I missing something, or this is not the right way to solve my problem. Does anybody has a better solution? Any advice will be greatly appreciated!
Uros
|
|
|
|
|
Study this example. The Bitmap Effect is a complex class and not just properites, so the trigger must set the properties different.
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Window1" x:Name="Window" Title="Window1" Width="640" Height="480">
<Window.Resources>
<ControlTemplate x:Key="ButtonControlTemplate1" TargetType="{x:Type Button}">
<Canvas Width="136" Height="52" x:Name="layoutRoot">
<Canvas.BitmapEffect>
<BevelBitmapEffect />
</Canvas.BitmapEffect>
<Ellipse Width="136" Height="52" Fill="#FFF05151" Stroke="#FF000000" />
</Canvas>
<ControlTemplate.Triggers>
<Trigger Property="HorizontalContentAlignment" Value="Right">
<Setter Property="BitmapEffect" TargetName="layoutRoot">
<Setter.Value>
<BevelBitmapEffect LightAngle="225" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Window.Resources>
<Grid x:Name="LayoutRoot">
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Content="Button" Template="{DynamicResource ButtonControlTemplate1}" HorizontalContentAlignment="Center" />
</Grid>
</Window>
Cheers, Karl
» CodeProject 2008 MVP
» Microsoft MVP - Client App Dev
My Blog | Mole's Home Page | MVP Profile
Just a grain of sand on the worlds beaches.
-- modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi all.
Iam new to Wpf..I want to know how to use crystal report In wpf?
Please help me
|
|
|
|
|
|
Good day folks,
Is it possible to use WPF's media components to create an MP3 player? I would want the MP3 player to have the usual functions (i.e. list of songs, time elapsed/left, random/sequential play, loop, fast forward, etc... you get the picture). Also, I would also want the user to be able to add mp3 to it.
Any help or direction you can provide will be greatly appreciated. Also, if WPF's media component can't do it, are there any third party MP3 player's for WPF?
Thanks,
BP
|
|
|
|
|
There are 100's of example programs using the MediaElement control on the web. Many here on Code Project.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi All!
Somebody Please Help/Guide me to complete my module.
Tools Used
-----------
Asp.Net Server Control (Asp.Net 3.5)
Windows XP
Code Behind is visual basic
My Module
----------
I want to create a Button control. When it is clicked a function named GoNext() will be called and the definition of the GoNext() will be given in the code behind of the EndUser WebForm(i.e where the control is going to be used).
My Source Code is:
------------------
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Text
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace SfNextCmd
<defaultproperty("text"), toolboxdata(=""><{0}:sfnextcmd runat="server">")> _
Public MustInherit Class SfNextCmd
Inherits Button
Public MustOverride Function GoNext()
Private Sub SfNextCmd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click
GoNext()
End Sub
End Class
End Namespace
Also if it is possible thro SilverLight Please send me the source code.
By Vijay
|
|
|
|
|
VijaySofist wrote: Also if it is possible thro SilverLight Please send me the source code.
Just calling a function on click event? It's possible to do in Silverlight. Just place a button on Page.xaml and subscribe the click event on constructor of Page.xaml.cs. Then, call the function..
If you are not familiar with Silverlight, please read this doc. http://www.silverlight.net/quickstarts/managed.aspx[^]
Hope it helps.
|
|
|
|
|
|
Hi Michael!
First of all thanks for the Reply yaar.
I was possible to Create a Button COntrol in SilverLight and able to Call a Function in the Click Event of that control. But it expects me to give the definition of that function Name in the same code behind window of the XAML.
What I want is just to call that function in the Click event and give that definition in the place where that Button Control is going to be used (i.e the end user code behind form). It must be Just like a MustOverride Function.
Thanks and Regards
Vijay. R
|
|
|
|
|
VijaySofist wrote: But it expects me to give the definition of that function Name in the same code behind window of the XAML.
I'm really not sure what you meant. There are only two things such as XAML file (e.g. Page.xaml) and code-behinded file (e.g. Page.xaml.cs )So, I'm not sure what you meant by "behind window of the XAML"
VijaySofist wrote: It must be Just like a MustOverride Function.
MustOverride used to use in base class and the property or method that use MustOverride need to be overridden in child class.
Are you talking about User Control Inheritance in Silverlight? If yes, there is one example about that in my blog.
|
|
|
|
|
Let me explain thro an example.
In Asp.Net when we create a New Project using Asp.Net Server Control, after the compilation of that project we can get a .dll File in the name of that project. We can use that .dll as a Control in any of the Separate ASP.Net project.
Like the same i am trying to make a Silverlight control.
What I meant by code behind is that aspx.vb (Separate Asp.Net Project page where that silverlight control is used)
Thanks and Regards
Vijay. R
|
|
|
|
|
Okay. Let me explain about Silverlight control and Silverlight Application.
Yes. You can create a ASP.NET control library and you can use it in any ASP.NET project.
The same goes for Silverlight. You can create a Silverlight control library and compile it as a .dll. then, you can use it in "Silverlight Application" (Not ASP.NET application.). So, the layout will be like that below.
-- ASP.NET WebSite
-----aspx (ASP.NET Page)
------xap (Silverlight 2 Application)
--------.dll (Siverlight 2 Control )
You can take a look at this sample[^] if you want to know how to use Silverlight control in Silverlight application and how to use SIlverlight application in ASP.NET.
Yes. All I'm talking about is Silverlight 2 beta1.
Hope it helps.
|
|
|
|
|
Hi,
I'm trying to get my mind around a problem I'm having with WPF. It can easily be compared to something like a stacked-bar chart (BTW, that's not what I'm creating, so please don't point me to a library providing these). Visually the results should look something like this:
NameA |-----||-----------||----|<br />
NameB |---------||-----------------|<br />
NameC |---||----------||-|
At the moment I have an Observable collection of data that provides me with two types, the string for the name and another collection with the values. I have used a ListView to display my table and the values are represented by an ItemsControl putting the data values inside a horizontally organized StackPanel .
<ListView ItemsSource="{Binding Source={StaticResource ResourceKey=data}}" Grid.Row="0" x:Name="myGrid">
<ListView.View>
<GridView>
<GridViewColumn Header="Name" DisplayMemberBinding="{Binding Path=Name}"/>
<GridViewColumn Header="Values">
<GridViewColumn.CellTemplate>
<DataTemplate>
<!-- Bind each item to the valueTemplate -->
<ItemsControl ItemsSource="{Binding Path=Values}"
ItemTemplate="{StaticResource valueTemplate}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView> The valueTemplate is implemented as this in the Windows.Resources block:
<DataTemplate x:Key="valueTemplate">
<Border Width="{Binding}" CornerRadius="2" >
<TextBlock Text="{Binding Title}" FontWeight="Bold" />
</Border>
</DataTemplate> Notice that the Width is, in the example above, set by a TypeConverter which takes an object of my datatype and returns a double corresponding to the width I want.
This works and the appearence is as desired. What I want to do now is make the "scale" of the displayed data change (not everything) e.g. if the value is 10, it is currently displayed as 10 pixels wide. I'd like to be able to adjust a slider to 2.0 and have the displayed data show as 20 pixels wide.
To attempt this, I've tried two main things:- Having my slider update a value that the
TypeConverter can see. When doing this, I can not seem to find any way to make the controls "redraw" using my new values. This also feels the wrong way to do things as the backend shouldn't need logic to affect the displayed output!
- Having the slider start animating the ScaleX element of a modified valueTemplate.
For the scaling, I've added the following to the valueTemplate
<Border.LayoutTransform>
<ScaleTransform x:Name="myScale" ScaleX="1.0" ScaleY="1.0" />
</Border.LayoutTransform> and a Slider like this:
<Slider x:Name="Scale" Width="100" Minimum="0.5" Maximum="10.0" Value="1.0">
<Slider.Triggers>
<EventTrigger RoutedEvent="Slider.ValueChanged">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="myScale"
Storyboard.TargetProperty="ScaleX"
To="{Binding ElementName=Scale,Path=Value}"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Slider.Triggers>
</Slider> The above code gives me an error 'myScale' name cannot be found in the name scope of 'System.Windows.Controls.Slider'. which makes some sense to me, but I can't see how to address the "name" defined inside of a template.
I've now hit a wall and don't know where to go next! Should I be defining a simple double in my resources and changing that? How can I define that (I assume I need to bring in some other namespace)? Can simple math be performed inside something like a Width field? Can anyone help me?
Regards,
Ray
|
|
|
|
|
Hi Ray,
Looks like your first problem is you need to have some sort of "shared" scale factor. You won't be able to access the element named 'myScale'. Since it's defined in a DataTemplate, there would be any number of elements with this name, so it would only be valid in the DataTemplate definition.
For the second problem, you say that you are using a TypeConverter, is that correct? If it is, then you will not be able to get the "values" refreshed automatically. Meaning you would have to refresh the bindings when the scale slider is moved.
What you can do is this:
1. Create a separate class (e.g. ScaleFactor) with a single property (e.g. Value)
2. Implement INotifyPropertyChanged in the ScaleFactor class and fire it when the Value changes.
3. Create an IMultiValueConverter that takes two values: 1st will be the "value" from your underlying data (you don't have to use a TypeConverter, but you probably can), 2nd will be the scale factor. The IMultiValueConverter will then multiply the two values and return that.
4. Define an instance of ScaleFactor in the Window's resource section.
5. Define an instance of your converter from #3 in the Window's resource section.
6. Update the Border's width to be a MultiBinding using your converter with the "value" and scale factor (from #4) as your input values.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Tom,
thanks for your reply. Your suggestions make a lot of sense and have, I feel, pointed me in the right direction. Although I think I'm messing up on step 6!
This is what I've done so far:
TJoe wrote: 1. Create a separate class (e.g. ScaleFactor) with a single property (e.g. Value)
2. Implement INotifyPropertyChanged in the ScaleFactor class and fire it when the Value changes.
public class VisualScale : INotifyPropertyChanged
{
private double scale = 1.0;
public double ScalingFactor
{
get { return scale; }
set { scale = value; NotifyPropertyChanged("Scale changed"); }
}
#region INotifyPropertyChanged Members
private void NotifyPropertyChanged(String info)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(info));
}
}
public event PropertyChangedEventHandler PropertyChanged;
#endregion
} TJoe wrote: 3. Create an IMultiValueConverter that takes two values: 1st will be the "value" from your underlying data (you don't have to use a TypeConverter, but you probably can), 2nd will be the scale factor. The IMultiValueConverter will then multiply the two values and return that.
public class WidthScaler : IMultiValueConverter
{
#region IMultiValueConverter Members
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ( targetType != typeof(double) )
{
throw new NotSupportedException("Target type of WidthScaler must be double");
}
if ( values.Length != 2 ||
values[0].GetType() != typeof(double) ||
values[1].GetType() != typeof(double) )
{
throw new NotSupportedException("Source values should be a pair of doubles");
}
return (double) values[0]*(double) values[1];
}
public object[] ConvertBack(object value,
Type[] targetTypes,
object parameter,
System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
} TJoe wrote: 4. Define an instance of ScaleFactor in the Window's resource section.
5. Define an instance of your converter from #3 in the Window's resource section.
<Window.Resources>
<local:Database x:Key="data" x:Name="data"/>
<local:VisualScale x:Key="scale" x:Name="scale" />
<local:WidthScaler x:Key="widthScaler" x:Name="widthScaler" /> TJoe wrote: 6. Update the Border's width to be a MultiBinding using your converter with the "value" and scale factor (from #4) as your input values.
<DataTemplate x:Key="programmeTemplate">
<Border>
<Border.Width>
<MultiBinding Converter="{StaticResource widthScaler}"
ConverterParameter="">
<Binding Path="{Binding Duration}" />
<Binding Path="widthScaler"/>
</MultiBinding>
</Border.Width>
I think I've either made the mistake in the bit above, or this bit...
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0" Value="{Binding Path=widthScaler}"/>
This is the exception I get is "A 'Binding' cannot be set on the 'Path' property of type 'Binding'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject. ". Whilst your reply has helped a lot, I've obviously not got the WPF gene kick in yet!
Regards,
Ray
|
|
|
|
|
I'm going to reply to myself as looking at the code I wrote I'd made an obvious mistake. Note, I still get the same exception but the following code is now used:
<Slider x:Name="scaleSlider" Width="100" Minimum="0.5" Maximum="10.0"
Value="{Binding ElementName=scale, Path=ScalingFactor}"/> and
<Border.Width>
<MultiBinding Converter="{StaticResource widthScaler}"
ConverterParameter="">
<Binding Path="{Binding Duration}" />
<Binding ElementName="scale" Path="ScalingFactor"/>
</MultiBinding>
</Border.Width> Hopefully this is now a little closer to the correct solution! Is it?
Regards,
Ray
|
|
|
|
|
Hi Ray,
Following the exception, this line is bad:
<Binding Path="{Binding Duration}" />
So here you are binding the Path property of a Binding object to the Value stored in the Duration property. You are basically double defining your binding statement. This needs to be:
<Binding Path="Duration" />
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|