|
I think u want to have some value in label when mouse is down. If so then call a method on MouseDown event and assign the value to the label as LABE.Text=value
Gomathi R
|
|
|
|
|
i am asking about binding with an function
I am writing an function mouse_down in a class
and i have to bind the function with this xAML code
can i do this
|
|
|
|
|
Can u explain me clearly. By finding a function means ,what value you are going to bind?
Gomathi R
|
|
|
|
|
Actually, it's easier than that.
<Label MouseDown="my_event_handler" />
No need for binding here. To make it even easier, once you enter the name of the event handler, you can right-click on it and pick "Navigate to Event Handler". It'll automatically create the function if it doesn't already exist.
|
|
|
|
|
I have a datagrid with itemsource as list.
There should a column such that it will display image as well as text (Filename).
The image will get displayed as per the filename extension, e.g. if the filename is test.doc then the word icon gets displayed and if the filename is test.pdf then the pdf icon gets displayed.
Both the icon and the filname should remain in one column.
And the datagrid should be filled at runtime with a webservice which gives the list.And the itemsource for the datagrid is that list.
Can we acheive that?
Thanks in advance,
|
|
|
|
|
salon wrote: Both the icon and the filname should remain in one column.
You can use a DataGridTemplateColumn[^] to specify the template for the column.
salon wrote: The image will get displayed as per the filename extension
One way you could do that is to use a IValueConverter[^] that takes the filename
and returns a URI for the appropriate bitmap based on the filename extension.
You would use this valueconverter in the Image.Source binding for the image in
your column template.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
For drag and drop of the video according to users choise using silverlight controls in web page.
Ch.Gayatri Subudhi
|
|
|
|
|
Here's a simple example of drag and drop. I used Rectangle objects here, but the same
principles apply to dragging and dropping any element...
<Grid x:Name="LayoutRoot" >
<Canvas >
<Rectangle Height="100" Width="100" Stroke="#FFFF0000" StrokeThickness="2" Fill="#00000000" Canvas.Top="42" Canvas.Left="44" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseMove="Rectangle_MouseMove" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp" />
<Rectangle Height="100" Width="100" Stroke="#FFFF0000" StrokeThickness="2" Fill="#00000000" Canvas.Top="97" Canvas.Left="109" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseMove="Rectangle_MouseMove" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp" />
<Rectangle Height="100" Width="100" Stroke="#FFFF0000" StrokeThickness="2" Fill="#00000000" Canvas.Top="145" Canvas.Left="169" MouseLeftButtonDown="Rectangle_MouseLeftButtonDown" MouseMove="Rectangle_MouseMove" MouseLeftButtonUp="Rectangle_MouseLeftButtonUp" />
</Canvas>
</Grid>
Point anchorPoint;
Point currentPoint;
bool isInDrag = false;
private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
FrameworkElement anno = sender as FrameworkElement;
anchorPoint = e.GetPosition(null);
anno.CaptureMouse();
isInDrag = true;
e.Handled = true;
}
private void Rectangle_MouseMove(object sender, MouseEventArgs e)
{
if (isInDrag)
{
FrameworkElement anno = sender as FrameworkElement;
currentPoint = e.GetPosition(null);
double x = System.Convert.ToDouble(anno.GetValue(Canvas.LeftProperty));
double y = System.Convert.ToDouble(anno.GetValue(Canvas.TopProperty));
anno.SetValue(Canvas.LeftProperty, x + currentPoint.X - anchorPoint.X);
anno.SetValue(Canvas.TopProperty, y + currentPoint.Y - anchorPoint.Y);
anchorPoint = currentPoint;
}
}
private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (isInDrag)
{
FrameworkElement anno = sender as FrameworkElement;
anno.ReleaseMouseCapture();
isInDrag = false;
e.Handled = true;
}
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
through canvas we need events of mouse.
what have to do,If we put the mediaplayer control of visual studio 2008 for that same drag and drop and placed haffazardly plz help me.
Ch.Gayatri Subudhi
|
|
|
|
|
Hello.
I have some storyboards created in Blend, however I don't want them triggered from the XAML but from the code behind (from an if function). I've Googled but found no answer, just more people asking the same thing.
Can anyone please let me know how this works?
Regards, E.
|
|
|
|
|
All you need to do is retrieve your animation as a Storyboard. Here's a sample you can try:
<Window
x:Name="Window"
x:Class="TriggerApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="640"
Height="183"
Title="Window1">
<Window.Resources>
<Storyboard x:Key="OnClick1">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="button1"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="326"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="button1"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="19"/>
</DoubleAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="button1"
Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[3].(GradientStop.Color)">
<SplineColorKeyFrame
KeyTime="00:00:01"
Value="#FFB41212"/>
</ColorAnimationUsingKeyFrames>
<ColorAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="button1"
Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
<SplineColorKeyFrame
KeyTime="00:00:01"
Value="#FFD57C7C"/>
</ColorAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="ButtonBase.Click"
SourceName="button">
<BeginStoryboard Storyboard="{StaticResource OnClick1}"/>
</EventTrigger>
</Window.Triggers>
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button
x:Name="button"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Button"/>
<Button
x:Name="button1"
Grid.Row="1"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Click="button1_Click"
Content="Button"
RenderTransformOrigin="0.5,0.5">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Button.RenderTransform>
</Button>
</Grid>
</Window> Then, all you need to do to retrieve the animation and play it is
Storyboard anim = TryFindResource("OnClick1") as Storyboard;
anim.Begin(); I hope that this helps.
"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
|
|
|
|
|
Hello. Thanks for that, am I correct is assuming the lower chunk of code is the code behind?
|
|
|
|
|
Yes - I included both bits to give you a bit of context, and a chance to experiment yourself.
"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
|
|
|
|
|
Hi.
Yep, it's working now. I had to take out all the triggers Blend creted for me and then used the following code to trigger from the code behind.
Storyboard lowLoadIn = (Storyboard)FindResource("lowLoadIn");
lowLoadIn.Begin(this);
Thanks for your help.
|
|
|
|
|
You're welcome, but try to use Storyboard lowLoadIn = FindResource("lowLoadIn") as Storyboard; instead. This doesn't throw an exception if the resource can't be found (it leaves lowLoadIn as null).
"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
|
|
|
|
|
Good people,
So, I do not want to go through a slew of controls to change my single line XAML control declarations in order to enable proper data validation. As you know, most of the times Expression Blend emits single line XAML for your controls. The only examples of validation deployment in XAML has the entire control declaration spread out over several lines.
My workaround is to do data validation (e.g. check for ranges, proper format, etc...) in the value conversion process. Yes, I know it's a hack.
My question is: will my program suffer greatly? What do I loose by performing data validation in the value conversion process? I have tested it (pre-Beta) and it seems to work fine. I even do notification - using my very own dialog box if I may proudly add . By the way, I write the value converters in C# and then assign them in Blend.
Thanks for any insight or opinions you can provide.
I know, I know; you could possibly use the "Lazy Developer" tag for this - LOL!
Blitz
|
|
|
|
|
Or, you could use the MVVM pattern and do validation in the ViewModel. Take a look at Sacha's article here[^] or my blog post here[^] for more information.
"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
|
|
|
|
|
Thanks, I am going to take a look.
|
|
|
|
|
I have a datagrid control in Silverlight. I want to set the background color of first column as white and the rest of the columns as gray.
I know we can do this in case of rows but can we set color of a particular column?
Also on mouse over on the particular row the background color of the selected row should change and color of the first column should remain as it is....
Can we do that?
Thanks in advance,
|
|
|
|
|
<saddevelopermode>
My copy of Programming WCF Services by Juval Lowy just arrived!!!! Get in!!!!
</saddevelopermode>
|
|
|
|
|
Oh dear. Now if only you'd talked to me beforehand, I'd have recommended against this book - I found it to be simply awful. I have huge respect for Juval, but this book keeps telling you to refer to things in other books that he's written, and that's not good in my mind.
"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
|
|
|
|
|
Damn, your kidding ... I originally had the Pro WCF book which I found near useless in its explanations and had read really good reports about the Juval book ...
|
|
|
|
|
How to place silverlight controls for multiple videos which are placing in haffazard manner in a web page where there we have the options for themes for selecting the background screen.Please help me out..
Ch.Gayatri Subudhi
|
|
|
|
|
Multiple Silverlight controls on an html/aspx page or multiple controls
on a single Silverlight page?
For the former, you should maybe post your question on a more appropriate board,
like Web Development[^].
For the latter, you could place controls "haffazard" by placing them on
a Canvas.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for Your concern.
In this url http://1dc.net/album how the controls are placed exactly like we have the clients requirement.Plz give me suggestion.
Ch.Gayatri Subudhi
|
|
|
|