WPF(add a message or text in the xmal elements like ellipse at run time in windows application. [modified]
-
Hi.. I am new to this concept.How to add a message or text in the ellipse of xmal element at run time of windows application.Is in a xmal ellipse control we can put text box to write text? if yes how, if not please suggest me the other way if possible... the code : Ellipse x:Name="C2" Height="353" Width="440" Stroke="LightPink" StrokeThickness="05" Visibility="Hidden" Fill="blue" Canvas.Top="63" Canvas.Left="80"> modified on Tuesday, May 5, 2009 12:54 AM
-
Hi.. I am new to this concept.How to add a message or text in the ellipse of xmal element at run time of windows application.Is in a xmal ellipse control we can put text box to write text? if yes how, if not please suggest me the other way if possible... the code : Ellipse x:Name="C2" Height="353" Width="440" Stroke="LightPink" StrokeThickness="05" Visibility="Hidden" Fill="blue" Canvas.Top="63" Canvas.Left="80"> modified on Tuesday, May 5, 2009 12:54 AM
You're looking at the problem from the wrong end: An ellipse does not have the opportunity to display text, but a Label can take whatever look you want through a control template :)
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type Label}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Label}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<Label Width="200" Height="100" Style="{StaticResource EllipseLabel}" Content="hello world" />
</Grid>
...accordingly, if you change your label's content, the text changes.
NetDrives - Open Source Network Share Management
-
You're looking at the problem from the wrong end: An ellipse does not have the opportunity to display text, but a Label can take whatever look you want through a control template :)
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type Label}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Label}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<Label Width="200" Height="100" Style="{StaticResource EllipseLabel}" Content="hello world" />
</Grid>
...accordingly, if you change your label's content, the text changes.
NetDrives - Open Source Network Share Management
Sir, Thanks for your concern. i need the text like textbox while in rumn time wt we want we are inserting,like this way i want to write some thing in the ellipse at run mode of the windows appliaction. Thanks and Regards Ch.Gaytari
-
Sir, Thanks for your concern. i need the text like textbox while in rumn time wt we want we are inserting,like this way i want to write some thing in the ellipse at run mode of the windows appliaction. Thanks and Regards Ch.Gaytari
There's no problem doing that - you can change a label's content at runtime through a binding expression or code. It's a label, after all. even though it looks like an ellipse.
NetDrives - Open Source Network Share Management
-
There's no problem doing that - you can change a label's content at runtime through a binding expression or code. It's a label, after all. even though it looks like an ellipse.
NetDrives - Open Source Network Share Management
Could you please give the sample code of this problem.Thanks in advance. With Regards Ch.Gayatri
-
Could you please give the sample code of this problem.Thanks in advance. With Regards Ch.Gayatri
This is regular WPF 101 - just give the label in my sample a name like this:
<Label x:Name="myLabel" ... />
...and in code, set the text:
myLabel.Content = "this is easy";
NetDrives - Open Source Network Share Management
-
This is regular WPF 101 - just give the label in my sample a name like this:
<Label x:Name="myLabel" ... />
...and in code, set the text:
myLabel.Content = "this is easy";
NetDrives - Open Source Network Share Management
let the windows form having text box ok..whn its in run mode we are able to enter some value in it like this way i need to write some thing like text or message in the ellipse of the xmal elements.Or any other way to solve this solution .Please suggest me. Thanks Ch.Gayatri
-
let the windows form having text box ok..whn its in run mode we are able to enter some value in it like this way i need to write some thing like text or message in the ellipse of the xmal elements.Or any other way to solve this solution .Please suggest me. Thanks Ch.Gayatri
If you want to enter text, you need to style another control, e.g. textbox:
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" x:Name="PART\_ContentHost"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<TextBox Width="200" Height="100" Style="{StaticResource EllipseLabel}" Text="hello world" />
</Grid>
NetDrives - Open Source Network Share Management
-
If you want to enter text, you need to style another control, e.g. textbox:
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" x:Name="PART\_ContentHost"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<TextBox Width="200" Height="100" Style="{StaticResource EllipseLabel}" Text="hello world" />
</Grid>
NetDrives - Open Source Network Share Management
-
inside canvas also i can apply the given code in all these xmal elemts like ellipse,rectangular,square a.d so on..
-
If you want to enter text, you need to style another control, e.g. textbox:
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" x:Name="PART\_ContentHost"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<TextBox Width="200" Height="100" Style="{StaticResource EllipseLabel}" Text="hello world" />
</Grid>
NetDrives - Open Source Network Share Management
Thanks sir.
-
This is regular WPF 101 - just give the label in my sample a name like this:
<Label x:Name="myLabel" ... />
...and in code, set the text:
myLabel.Content = "this is easy";
NetDrives - Open Source Network Share Management
sir can i apply that code under canvas..
-
If you want to enter text, you need to style another control, e.g. textbox:
<Grid>
<Grid.Resources>
<Style x:Key="EllipseLabel" TargetType="{x:Type TextBox}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type TextBox}"> <Grid > <Ellipse Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Stroke="LightPink" StrokeThickness="05" Fill="blue" /> <ScrollViewer HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0" x:Name="PART\_ContentHost"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid.Resources>
<TextBox Width="200" Height="100" Style="{StaticResource EllipseLabel}" Text="hello world" />
</Grid>
NetDrives - Open Source Network Share Management
<pre></pre><Ellipse x:Name="C2" Height="353" Width="440" Stroke="LightPink" StrokeThickness="05" Visibility="Hidden" Fill="blue" Canvas.Top="63" Canvas.Left="80" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" ></Ellipse> <TextBox Name="TB5" Visibility="visible" Background="Transparent" Height="121" Width="218" Canvas.Top="179" Canvas.Left="223"></TextBox> ike this way also at run time we can write text,,is any mutiline set to true is any property is ther for texbox in WPF Thanks and Regards CH.Gayatri