|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
<Window x:Class="SreenDeginer.Window1"<br />
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"<br />
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"<br />
Title="Window1" Height="530" Width="852"><br />
<Canvas Height="498" Width="787"><br />
<Button Canvas.Left="40" Canvas.Top="10" Background="LightPink" Height="47" Width="73" Click="Button_Click" /><br />
<br />
<Canvas Height="422" Width="628" x:Name="c2" Background="Black" Visibility="Collapsed" Canvas.Left=" 20" Canvas.Bottom="5" Canvas.Top="67"><br />
<Rectangle Height="422" Width="56" Fill="Beige"></Rectangle><br />
<Rectangle Height="33" Width="628" Fill="Pink" Canvas.Left="0" Canvas.Top="0"><br />
<br />
</Rectangle><br />
<TextBlock Text="X" Canvas.Left="607" Foreground="Black" x:Name="ClBtn" MouseLeftButtonDown="TextBlock_MouseLeftButtonDown" Height="23" Width="21"></TextBlock><br />
<Ellipse x:Name="E1" Height="25" Width="39" Stroke="Black" Canvas.Left="09" Canvas.Bottom="324" Canvas.Top="40" Fill="LightPink" MouseLeftButtonDown="E1_MouseLeftButtonDown"><br />
</Ellipse><br />
<Ellipse x:Name="E2" Height="322" Width="523" Stroke="LightPink" StrokeThickness="05" Visibility="Hidden" Fill="Blue" Canvas.Top="63" Canvas.Left="80" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" ></Ellipse><br />
<Rectangle Name="MyRectangle" Stroke="Black" Width="39" Fill="LightPink" Canvas.Left="09" Canvas.Bottom="316" Height="17" MouseLeftButtonDown="R1_MouseLeftButtonDown"/><br />
<Rectangle Name="REC2" Height="258" Width="507" Visibility="Hidden" Stroke="LightPink" StrokeThickness="05" Fill="Blue" Canvas.Top="66" Canvas.Left="85" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" ></Rectangle><br />
<br />
<!--<Polygon x:Name="P1" Height="27" Width="39" Canvas.Left="09" Canvas.Bottom="600" Canvas.Top="125" Fill="LightPink" ></Polygon>--><br />
<br />
<Ellipse x:Name="C1" Height="25" Width="28" Stroke="Black" Canvas.Left="09" Canvas.Bottom="600" Canvas.Top="125" Fill="LightPink" MouseLeftButtonDown="C1_MouseLeftButtonDown" ></Ellipse><br />
<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><br />
<Rectangle Name="Square" Height="27" Width="39" Stroke="black" Canvas.Left=" 09" Canvas.Top="170" Fill="LightPink" MouseLeftButtonDown="SQ1_MouseLeftButtonDown"></Rectangle><br />
<Rectangle Name="SQ1" Height="290" Width="290" Stroke="LightPink" StrokeThickness="05" Visibility="Hidden" Fill="Blue" Canvas.Top="63" Canvas.Left="85" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" ></Rectangle><br />
<Polygon Name="T1" Points="70,70 40,1 1,70" Stroke="black" Fill="LightPink" Height="38" Width="57.9" Canvas.Top="215" Canvas.Right="580" MouseLeftButtonDown="T1_MouseLeftButtonDown" /><br />
<Polygon Name="T2" Points="500,252 252,03 25,250" Stroke="LightPink" StrokeThickness="05" Fill="Blue" Visibility="Hidden" Height="300" Width="530" Canvas.Top="63" Canvas.Left="85" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" /><br />
<Polygon Name="S1" Visibility="Hidden" Stroke="Blue" StrokeThickness="1.0" Points="176.5,50 189.2,155.003 286.485,113.5 201.9,177 286.485,240.5 189.2,198.997 176.5,304 163.8,198.997 66.5148,240.5 151.1,177 66.5148,113.5 163.8,155.003" Canvas.Top="63" Canvas.Left="85" Fill="Blue" Height="332" Width="375" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" /><br />
<Polygon<br />
Name ="mypolygon1"<br />
Stroke="LightPink" <br />
StrokeThickness="03" <br />
Points="176.5,70 189.2,155.003 286.485,113.5 201.9,177 286.485,240.5<br />
189.2,198.997 176.5,304 163.8,198.997 66.5148,240.5 151.1,177<br />
66.5148,113.5 163.8,155.003" Height="343" Width="356" Fill="Blue" Canvas.Top="63" Canvas.Left="85" Visibility="Hidden" MouseMove="M1_MouseMove" MouseLeftButtonDown="M2_MouseLeftButtonDown" MouseLeftButtonUp="M3_MouseLeftButtonDown" /><br />
<br />
<br />
<br />
</Canvas><br />
<br />
</Canvas><br />
</Window><br />
|
|
|
|
|
inside canvas also i can apply the given code in all these xmal elemts like ellipse,rectangular,square a.d so on..
|
|
|
|
|
|
<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
|
|
|
|
|
sir can i apply that code under canvas..
|
|
|
|
|
I give up, can't find any good information about this anywhere
I have a UserControl with 6 textboxes. I have a quite complex datastructure from where I want to fill these textboxes. The datastructure contains several sets of "String[6]" but I can't figure out how to bind it
public partial class MyAttBox : UserControl
{
public static DependencyProperty LowChRXProperty = DependencyProperty.Register("LowChRX", typeof(String), typeof(MyAttBox));
public String LowChRX
{
get { return (String)GetValue(LowChRXProperty); }
set { SetValue(LowChRXProperty, value); }
}
}
"main" XAML:
<AttBox:MyAttBox Header="GSM 850" x:Name="AttBox_GSM850" />
my data is stored like:
public class ABC
{
private Dictionary<String, List<String>> m_values = new Dictionary<String, List<String>>();
public Dictionary<String, List<String>> Values
{
get { return m_values; }
set { m_values = value; }
}
What I want to is to select a Key in my code and connect the Values to the texboxes in my UC. How?
|
|
|
|
|
I'm confused...
mikla521 wrote: The datastructure contains several sets of "String[6]" but I can't figure out how to bind it
Then why didn't you show these "sets of "String[6]""??
The 6 textboxes....you want to bind those by index to 6 strings in a collection, right?
And that collection of 6 strings - where is that? Is that the List<> in each dictionary entry?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ok, will try refine myself here
public class CouplerDB
{
private Dictionary<String, Coupler> m_products;
....
}
public class Coupler
{
private Dictionary<String, Attenuation> m_attenuations
....
}
public class Attenuation
{
private Dictionary<Band, List<String>> m_values = new Dictionary<Band, List<String>>();
I want my user control textboxes to display the values from the List<String>
but it's not absolute necessary to have that list, just a place to store 6 different value.
Scenario: In a listbox I can select a product. Radiobuttons to select Coupler. Then I have a UserControl for each Band which I want to display the corresponding Strings. Clear?
*Sigh*
If I change Coupler I need to change the binding.
Another way to do it is to hardcode everything, but then I need almost 60 UserControls with a total of 360 Textboxes! My way I "only" need maximum 10 UserControls...
|
|
|
|
|
mikla521 wrote: Clear?
No.
mikla521 wrote: Radiobuttons to select Coupler
Select a coupler from where? You only show one coupler per product in the m_products dictionary.
How do you know how many radiobuttons there should be?
Are any of these dictionaries fixed count? Which ones?
It loks on the outside like a (relatively) simple 3-level master-detatil scenario.
I just want to try to put together a sample for you and it would be easiest
if I know and understand the data you're working with
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I will try again
A listbox where I can select product, nothing strange here.
Then a Tab with 6 radiobuttons to select Coupler and in that same Tab I have my UserControls.
So when I change selectedItem in my listbox OR change radiobutton, I need to update my UserControls with new data.
ONE of the UserControls in my XAML looks like:
<AttBox:MyAttBox Header="GSM 850" x:Name="AttBox_GSM850"/>
In my code I have (don't care about the private members now, let's say they are public ):
public CouplerDB myDB = new CouplerDB When I want to change in the UC I get the values from:
Product p = (Product)productListbox.SelectedItem;
myDB.m_products[p.ProductName].m_attenuations["Cable"].Values[Band.GSM850][0]
myDB.m_products[p.ProductName].m_attenuations["Cable"].Values[Band.GSM850][1]... so I can set
AttBox_GSM850.LowChRX = myDB.m_products[p.ProductName].m_attenuations["Cable"].Values[Band.GSM850][0];
But to simplify things here... If I have ONE and only ONE UC. I want a Dictionary where each KEY selects, i.e a List<String> to populate the UC listboxes, also want TwoWayBinding. Ehh..I have a testproject, where can I post it?
|
|
|
|
|
Been trying around a little...
If my data object looks like:
public class MyData : INotifyPropertyChanged
{
private String m_LowChRX;
private String m_LowChTX;
public String LowChRX
{
get { return m_LowChRX; }
set { m_LowChRX = value; OnPropertyChanged("LowChRX"); }
}
public String LowChTX
{
get { return m_LowChTX; }
set { m_LowChTX = value; OnPropertyChanged("LowChTX"); }
}...
In my code I can set the data values in
MyData myData1; And use binding like this
binding = new Binding("LowChRX");
binding.Source = myData1;
myBox.tbLowChRX.SetBinding(TextBox.TextProperty, binding); where myBox is my UC. And, again, I have 6 textboxes in myBox. Then I have to repeat that binding for each textbox. And here is the point where I change from myData1 to other data objects.
If I have a List<String> in my UC, how do I bind it? When then TextBox is a Control, maybe I have to make a custom control inside which hold my List? So I can bind like:
myBox.CustomControl.SetBinding(Property, binding)
Am I on the right track now?
|
|
|
|
|
You can use Binding with the DependencyProperty.
You can get information on how to implement the DependencyProperty in this blog:
How to Implement a DependencyProperty?
Try with that. It will work.
|
|
|
|
|
WPF gives you a couple options here. I'll just show them in XAML and let you decide what you want and translate to code-behind if you want. All of these examples assume you have an object of type ABC as the DataContext.
Option A - Bind to a specific list with a known key:
<ListBox ItemsSource="{Binding Values[KeyToGetItems]}" />
Option B - Bind to the entire list with another set of controls for the current item:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ListBox Name="lstValues" ItemsSource="{Binding Values}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Key}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="1" ItemsSource="{Binding SelectedItem.Value, ElementName=lstValues}">
<!-- other controls here -->
</StackPanel>
</Grid>
|
|
|
|
|
Hi All,
I have seen an application which will change the non client area of any windows using in my system. and the application is cristalxp theme.
Now my doubt is along with the application he gave few images which are in png format, Here I would like to expain on image
He has close button image which is simmilar to Vista Close button and in the same image it self he has five more images i.e
one for maximised mouse over,
one for maximised mouse leave,
one for minimized mouse over,
one for minimized mouse leave,
when ever i do some event on the cloe button rexpective image is getting loaded.
I felt that is wow single image with multiple images and loading respectivly.
If some know this logic will you please let me know.
Thanks and Regards
Seshu
|
|
|
|
|
I'm not sure what you're asking here, but AFAIK, there's no support
in PNG for multiple frames in a single image.
The BitmapFrame class can be used as an ImageSource for individual frames
in a multi-frame image if the format supports it (TIFF and GIF in WPF).
So....what are you asking?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Even I read the same in many forums but Recently i have downloaded an application as such and just as i could upload those images i couldnt show you here.
Any how thanks for your reply and i will get back on this once after having any idea in this regards
<b>Thanks </b>
Seshu
|
|
|
|
|
Overview
WPF Project (VS 2008)
I'm using a ListView (with GridView) bound to an ObservableCollection. The collection includes a DateTime field.
When I populate the collection, the DateNR field is often null, but then the ListView displays a date of "01-Jan-01"!!
How do I stop this as I don't want the user to see a date when there shouldn't be one. I need the DateNR field in the collection to be a DateTime value not a string because this column is used for sorting.
Any ideas would be welcome. thanks
<br />
public class RecordData<br />
{<br />
public int ID { get; set; }<br />
public DateTime DateNR { get; set; }<br />
}<br />
The GridView column for 'DateNR' is specified as follows:
<br />
GridViewColumnHeader gvch = new GridViewColumnHeader();<br />
GridViewColumn gvc = new GridViewColumn();<br />
Binding bind = new Binding("DateNR");<br />
bind.Converter = new FormattingConverter();<br />
bind.ConverterParameter = @"{0:dd-MMM-yy}";<br />
gvc.Width = 80;<br />
gvc.DisplayMemberBinding = bind;<br />
gvch.Content = "NR Date";<br />
gvc.Header = gvch;<br />
myGridView.Columns.Add(gvc);<br />
<br />
SqlConnection sqlConn = new SqlConnection(myConnectionString);<br />
SqlCommand sqlComm = new SqlCommand("...", sqlConn);<br />
SqlDataReader sqlDR = sqlComm.ExecuteReader();<br />
RecordData rd = new RecordData();<br />
rd.ID = sqlDR.GetInt32(0);<br />
if (sqlDR.IsDBNull(1) == false)<br />
rd.DateNR = sqlDR.GetDateTime(1);<br />
_MyCollection.Add(rd);<br />
modified on Saturday, September 19, 2009 5:46 AM
|
|
|
|