|
Hi Guys,
I have created two xaml files , 1. Page1.xaml and 2. Page2.xaml
Page1.xaml has a Hyperlink with click event associated with a method as below:
<Grid>
<TextBlock>This is a <Hyperlink Name="myLink" Click="hyperlink_Clicked">hyperlink</Hyperlink> to page 2</TextBlock>
</Grid>
In page1.xaml.cs, i have created the method hyperlink_Clicked as below:
private void hyperlink_Clicked(object sender,System.EventArgs erg)
{
System.Uri myUri = new Uri("Page2.xaml",System.UriKind.Relative );
myLink.NavigateUri = myUri;
}
However, when i click on hyperlink for the first time, it does not navigate to page2, but if i click second time it goes to page2. Am i missing anything? late Binding or early binding?
Any help , appreciated.
Thanks
happy coding!
|
|
|
|
|
Without having tryed to reproduce your issue I suspect that the link would only work if it is in a focused control and that it is not the case when you first click.
Setting the focus reliably can only be done in the Loaded event, as it is well undocumented! , I suggest you write something as follow:
MyControl()
{
Loaded += (sender, e) => { Focus(); };
}
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.
|
|
|
|
|
I have two sahpes created using Path which has Data Property. One Path is smaller and the other is Larger. I want to animate smaller Path and make it look like larger path. Please suggest me how to do this.
Path 1 :
path strokethickness="2.000000" stroke="#000000" fill="#000000" data="F1 M 148.692383,566.845703 L 198.179199,566.845703 L 197.963867,545.753906 L 197.757324,525.583984 L 138.201660,525.583984 C 138.201660,525.583984 139.660156,534.376953 141.660156,541.126953 C 143.660156,547.876953 148.692383,566.845703 148.692383,566.845703 Z" width="87.077" stretch="Fill"
Path 2 :
path strokethickness="2.000000" stroke="#000000" fill="#000000" data="F1 M 200.701172,444.335938 C 200.701172,444.335938 201.902344,454.123047 201.902344,467.187500 C 201.902344,477.767578 201.246582,481.021484 199.109375,489.334961 L 129.755859,489.334961 C 124.140625,485.524414 120.946777,474.328125 120.035156,463.418945 C 119.187988,453.281250 124.750488,444.418945 124.750488,444.418945 L 200.701172,444.335938 Z" stretch="Fill"
Thanks In advance.
|
|
|
|
|
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="DemoAnim.Window1"
x:Name="Window"
Title="Window1"
Width="640" Height="480">
<Window.Resources>
<Storyboard x:Key="GrowEllipse">
<doubleanimationusingkeyframes begintime="00:00:00" storyboard.targetname="ellipse" storyboard.targetproperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" mode="hold" /> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1.643"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1.643"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource GrowEllipse}"/>
</EventTrigger>
</Window.Triggers>
<Grid x:Name="LayoutRoot">
<Ellipse Fill="#FFFF0000" Stroke="#FF000000" Margin="176,127,0,214" StrokeThickness="5" Width="112" HorizontalAlignment="Left" x:Name="ellipse" RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
<Ellipse Fill="#FFFF0000" Stroke="#FF000000" StrokeThickness="5" Margin="0,91,75,178" Width="184" HorizontalAlignment="Right"/>
</Grid>
</Window>
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
I would be very grateful to anyone who would explain me what's wrong with my code.
In the code below I'm creating TextBoxes dynamically when user clicks on the TextBlock. I want each new TextBox be focused (i.e. the blinking cursor to be in the TextBox), but it works only for the first one. 2-nd, 3-rd and following TextBoxes became focused only when I switch to another tab in Firefox and than switch back again. How can I make the last created TextBoxes focused?
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace TextBoxCase
{
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
TextBlock txtBlock = new TextBlock();
txtBlock.Text = "Create new TexBox!";
txtBlock.MouseLeftButtonDown += txtBlockClick;
panel.Children.Add(txtBlock);
}
void txtBlockClick(object sender, MouseButtonEventArgs e)
{
TextBox txtBox = new TextBox();
txtBox.Loaded += new RoutedEventHandler(txtBox_Loaded);
panel.Children.Add(txtBox);
}
void txtBox_Loaded(object sender, RoutedEventArgs e)
{
((TextBox)sender).Focus();
}
}
}
In the xaml code I only have StackPanel named "panel".
|
|
|
|
|
Alex Skye wrote: ((TextBox)sender).Focus();
Maybe you can switch '((TextBox)sender).Focus();' with '((TextBox)sender).Activate();'
If this doesn't work will you post the way you fixed it?
Thanks
|
|
|
|
|
Can anybody share some piece of code about how to maintain session for every user logging in through WPF browser application.
|
|
|
|
|
|
Mis$Fit wrote: have been created a wpf listview consisiting gridview now i want to change the color where my gridview column has "Failed" value....how i can do this
Use a DataTrigger.
|
|
|
|
|
plz anyone can give me a sample code oor a link that can help me...
|
|
|
|
|
Google has lots, but perhaps this[^] one from our very own RockStar might help.
|
|
|
|
|
Why do folks delete OP ???
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer wrote: Why do folks delete OP ???
Because they're stupid.
|
|
|
|
|
HAHA!
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Hi,
can u help me know how to proceed with maintaining session state in wpf browser application.
|
|
|
|
|
Hi Puneet,
XBAP is a client side technology, and it cannot use session directly. XBAP is similar to WPF Windows application the main difference is that XBAP application runs on the browser. As you cannot use session in a standalone Windows application similarly session cannot be used in a XBAP application. However, if your web site is developed by ASP.NET, you can disable session cookies. Instead, the session id will be passed by a request parameter in the URL. Now you can use this parameter in your XBAP.
Hope this information will be helpful .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi...i'm new to wpf.
I have a problem and i dont find a solution on web.
I have an usercontrol (name PresenterControl.xaml) used as a container for other usercontrols (WindowContainerControl.xaml in this case). From code i think you'll understand what i;m trying to do.
The content of PresenterControl it;s a label. this content will be forwarded inside PresenterContent to WindowContainerControl. WindowContainerControl will put it inside a grid.
i;m getting this error and i have no solution in mind.
Key cannot be null.
Parameter name: key
at System.Collections.Specialized.ListDictionary.get_Item(Object key)
at System.Collections.Specialized.HybridDictionary.get_Item(Object key)
at System.Windows.StyleHelper.QueryChildIndexFromChildName(String childName, HybridDictionary childIndexFromChildName)
please help me if this issue can be solved and if i;m not asking too much please modify my example if you find a solution. thanks a lot.
Window1.xaml
<window x:class="WpfApplication3.Window1" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myControls="clr-namespace:WpfApplication3"
Title="Window1" Height="300" Width="300">
<grid>
<mycontrols:presentercontrol xmlns:mycontrols="#unknown">
<label>Label text</label>
</mycontrols:presentercontrol>
</grid>
</window>
PresenterControl.xaml
<usercontrol x:class="WpfApplication3.PresenterControl" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:myControls="clr-namespace:WpfApplication3"
Height="300" Width="300">
<usercontrol.contenttemplate>
<datatemplate>
<grid>
<border background="Black" height="30" verticalalignment="Top" />
<mycontrols:windowcontainercontrol xmlns:mycontrols="#unknown">
<contentpresenter margin="3" content="{TemplateBinding Property=Content}" />
</mycontrols:windowcontainercontrol>
</grid>
</datatemplate>
</usercontrol.contenttemplate>
</usercontrol>
WindowContainerControl.xaml
<usercontrol x:class="WpfApplication3.WindowContainerControl" xmlns:x="#unknown">
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<usercontrol.contenttemplate>
<datatemplate>
<grid>
<grid.rowdefinitions>
<rowdefinition height="20" />
<rowdefinition height="*" />
</grid.rowdefinitions>
<!-- Butoanele ferestrei -->
<border background="Red" grid.row="0" cornerradius="5,5,0,0">
<grid>
</grid>
</border>
<border background="Blue" grid.row="1" cornerradius="5,5,0,0">
<grid>
<contentpresenter margin="3" content="{TemplateBinding Property=Content}" />
</grid>
</border>
</grid>
</datatemplate>
</usercontrol.contenttemplate>
</usercontrol>
|
|
|
|
|
I wouldn't expect any of that to work!! Don't do things like:
<usercontrol x:class="WpfApplication3.WindowContainerControl" xmlns:x="#unknown">
Your cutting off the other xmlns statements that follow by using a > character at the end of that line for starters. I have no idea what your trying to do with:
xmlns:x="#unknown"
Are you making this XAML by hand in VS? I suggest you go and grab a trial version of Expression Blend and have a play around with that first.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
|
|
All you have done is define DataTemplates and ContentPresenters incorrectly.
You can almost think of statements like
<myC:WindowContainerControl>
As HTML #include statements. So trying to do things like:
<myC:WindowContainerControl>
<Grid>
<ContentPresenter Margin="3" Content="{TemplateBinding Property=Content}"/>
</Grid>
</myC:WindowContainerControl>
Is a bit weird really. If you want to do that you would have the control presenter *inside* the WindowContainerControl.
Take a step back and have a play with WPF in Blend before moving onto stuff like this, just a couple of days to get your head into the way it works the binding is really complex and not hugely intuitive to start with.
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
It's good i know that i didn't understand well the mechanism of template-ing and it;s not some bug or something like that. i will study deeper the subject. finally i solved my problem in a different approach.
Once again thanks for your help..as for me i'll do some blending )
|
|
|
|
|
Hi Everybody!
WPF is a great Framework. I love it!
My problem:
I created some polyline objects with Blend, exported and placed them into my window with a grid.
Now I resized my window and my objects resized too, but not as I would like it.
The objects moved in all directions. It looks ugly...
I want to achive a resizing method like stretching an image. Several parts should by resized or stretched as a whole. Maybe resizing the buffer where the objects are rendered?
Do you have a solution or idea?
Thank you!
|
|
|
|
|
|
Thank you! I tried it.
But how to put multiple objects (Images, polylines etc.) into one ViewBox?
|
|
|
|