|
Hi,
I have just started learning WPF and exploring more on WPF controls.
Can any one help how to display popup? I have used TextBlock under popup control as below :
<pre> <Popup StaysOpen="True">
<TextBlock Name="txtBlock1">
This is simple PopUp in WPF..
</TextBlock>
</Popup></pre>
But how to trigger this popup?
Thanks and regards,
Rahul Chitte
|
|
|
|
|
Popups are shown with the IsOpen method.
|
|
|
|
|
Two ways:
1) Give it a name (The Popup itself, not just the TextBlock), and open it in the code-behind
2) (The preferred method) Bind the Popup's IsOpen property to something else, such as a toggle button or a boolean field on your underlying model.
|
|
|
|
|
This sample [^]could help you out.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
That's a good example!
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
|
|
|
|
|
Thank you Tarun.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
OK; I have digested the depressing news I got in my "Data Access for Dummies" thread below and accepted that I need to create a Silverlight 4 client app and a WCF host service that supplies the data.
SFSG!
Of course, I want to create a common class library containing the DTO class definitions so that the host and the client can share the same definitions.
BUT!!! If I create a Silverlight class library, I can't use Ado objects to access the db (which I want to do), and if I create a "normal" windows class library, I can't reference it in my Silverlight client app.
So how can I do that???
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Do you know how WCF works? I'm not being funny, I'm just trying to find a common basepoint here. If you have your Silverlight app needing to know about Ado types, then you have just put a hard dependency in which means that your service could not be consumed by other types of systems (such as Java ones) that have no knowledge of the Ado types.
You create your model as a DataContract. Here's an example:
namespace WcfServer
{
using System;
using System.Runtime.Serialization;
[DataContract]
public class Customer
{
[DataMember]
public string Forename { get; set; }
[DataMember]
public string Surname { get; set; }
[DataMember]
public DateTime DateOfBirth { get; set; }
[DataMember]
public int Id { get; internal set; }
}
} As you can see, it's POCO. Now, the point here is that you don't add this as a class library into your Silverlight application. What you do, is import the service reference into your Silverlight application, so it gets access to the contract (and all the other gubbins it needs, such as the OperationContract ). You now have a nice separation in place which means that you can leverage things such as web farms to manage scalability of your service.
As you are new at this, I would recommend buying a book and reading up on this. There's a lot to it, and it's well worth the investment. The book I usually recommend for Silverlight is Silverlight 4 Unleashed[^] by MVP and Mix speaker, Laurent Bugnion.
|
|
|
|
|
All this is quite new to me, I've never used neither Silverlight nor WCF before and my knowledge about those techniques is quite limited, hence the stupid questions.
Thanks for having patience with me, though. I get your point above to a certain point. But isn't it so (with reference to your example) that the Customer class with its DataContract attributes needs to be defined and have identical definitions on both sides of the WCF wall? That is at least what I seem to recall having read somewhere.
Thanks for the book recommendation. I actually ordered that very book yesterday. But since it's going to take some time for it to arrive, I thought I'd get going by asking stupid questions in this Forum in the meanwhile...
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Johnny J. wrote: But isn't it so (with reference to your example) that the Customer class with
its DataContract attributes needs to be defined and have identical definitions
on both sides of the WCF wall?
Yes, but when you import the service reference, that comes with it. In other words, the proxy implementation that your Silverlight service calls is created for you - that's cool.
|
|
|
|
|
So when you change somthing in your service, you need to refresh or delete/readd your service reference?
Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Don't tell my folks I'm a computer programmer - They think I'm a piano player in a cat house... ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Yes. You import the contract, which creates a proxy implementation.
|
|
|
|
|
You need to pay Pete with a 5, thats an excellent explanation. Once you get over the initial STEEP learning curve it does make some sense. I got lucky, a corporate policy that the desktop is not allowed to connect directly to a database forced us to WCF and the move to SL was a natural from there.
I create the WCF in a separate project, the bulk of it can be built by a code generator as the CRUD operations (model and DAL/controller) are very standard.
The only real drawback that I have found is that a WCF does not allow a dynamic structure. Think of query a procedure an then just throw the result at a datagirdview in winforms, this is not the way SL/WPF works, EVERY thing needs to be defined, all the properties for the proc need to be in a model and that needs to be imported into the client and then you can use it in a datagrid. There is a work around for the dynamic stuff but it is painful.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can have a 5 both of you. Thanks a lot for the help. Right now, it does look like gibberish to me. I hope that when I get the book, things will brighten a bit...
Why can't I be applicable like John? - Me, April 2011 ----- Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Everybody is ignorant, only on different subjects - Will Rogers, 1924
|
|
|
|
|
Mycroft Holmes wrote: WCF does not allow a dynamic structure
Excellent point. You're right that you can get round it, but the effort of doing so doesn't justify the development needed to do it. I've been playing around with parsing dynamic ODATA structures, and it's just so much boilerplate and jiggery pokery that I'm seriously wishing I hadn't started it.
|
|
|
|
|
I use a structure from Telerik, return the data as xml to the client then parse it into the table/colum/row collections, this then dinds to the Telerik datagrid and I have a data dump utility from any stored proc.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
how to read the data from databinding list and display the data in a proper control(for ex: textbox)
wat i want to do here is, when user click on the listbox(lbDirectiveList) i want to display the selected DirectiveName in txtfilter.text and DirectiveDescription in txtdesc.text..
so can u tell me how to do it...
modified on Monday, April 18, 2011 3:01 AM
|
|
|
|
|
Do this :
void lbDirectiveList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
Directive dire = (Directive)lbDirectiveList.SelectedItem;
txtfilter.text = dire.DirectiveName;
txtdesc.text = dire.Description;
}
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
|
|
|
|
|
i have multiple Shapes in Canvas i want to move it together
i have tried some code but i have problems
first try
for (int i = 0; i < this.Children.Count; ++i)
{
double xOffset;
double yOffset;
double shapeTop = Canvas.GetTop(this.Children[i]);
double shapeLeft = Canvas.GetLeft(this.Children[i]);
xOffset = Convert.ToDouble(dropPoint.X -shapeClickPoint.Value.X);
yOffset = Convert.ToDouble(dropPoint.Y - shapeClickPoint.Value.Y);
TranslateTransform translateTransform = new TranslateTransform(xOffset, yOffset);
if (this.Children[i].IsEnabled)
{
this.Children[i].RenderTransform = translateTransform;
}
the problem when i translate the shapes returns to its position before translation
second try
for (int i = 0; i < this.Children.Count; ++i)
{
double shapeTop = Canvas.GetTop(this.Children[i]);
double shapeLeft = Canvas.GetLeft(this.Children[i]);
if (this.Children[i].IsEnabled)
{
Canvas.SetLeft(this.Children[i], -shapeLeft+ dropPoint.X - shapeClickPoint.Value.X);
Canvas.SetTop(this.Children[i], -shapeTop + dropPoint.Y - shapeClickPoint.Value.Y);
}
in second try the shapes toggle between mouse position and another position
how can i solve the issues
thank you
|
|
|
|
|
Why don't you use WPF animations? Thats what they are there for
|
|
|
|
|
i found the solution in article in codeproject
thank you and i'm sorry not to search first
|
|
|
|
|
Hello,
I have WPF application. I use this code with different messages (SetMessage method) throughout the application:
infoMessageDlg = new InfoMessage();
infoMessageDlg.SetMessage("Записи не найдены...");
infoMessageDlg.Show();
timer.Interval = TimeSpan.FromMilliseconds(800);
timer.Start();
The timer I use is this:
private DispatcherTimer timer = null;
InfoMessage infoMessageDlg = null;
public MainWindow()
{
...
timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Task);
}
It means dialog box appears for 800 milliseconds to display some message and closes automatically using this code:
private void timer_Task(object sender, EventArgs e)
{
infoMessageDlg.Close();
timer.Stop();
}
It works fine everywhere except in case I click listview item. The listview is bound to some data through its ItemsSource property. What happens? The dialog appears for very short time (almost not noticeable) and closes. It's much more shorter than 800 milliseconds.
The code looks like this:
private void lstvTestRuns_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
...
listTestLogs.ItemsSource = null;
listTestLogs.ItemsSource = lstTestLogs;
if (treeAdditionalInfo.Items.Count == 0 && listTestLogs.Items.Count == 0)
{
infoMessageDlg = new InfoMessage();
infoMessageDlg.SetMessage("Записи не найдены...");
infoMessageDlg.Show();
timer.Interval = TimeSpan.FromMilliseconds(800);
timer.Start();
}
...
}
Does anybody know what's going on here?
Thank you in advance for help.
modified on Thursday, April 14, 2011 1:53 AM
|
|
|
|
|
Hi
If virtualizingstackpanel provides better performance, should we then always choose virtualizingstackpanel over Grid/StackPanel then?
Under what circumstances should one choose Grid/StackPanel?
Thanks
dev
|
|
|
|
|
Actually VirtualizingStackPanel is mainly used to set the ItemsPanelTemplate for lets take an example for a ListBox where large data like 1000 or maybe 10,000 items or more have to be loaded into it.
You set it like this :
<ListBox Name="myListBox">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation = "Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
It means that you are setting the Panel for the ListBox so that "All" the items in ListBox can be arranged in a Vertical manner. Virtualization means that items will be created only when they are visible.
But if you substitute the VirtualizingStackPanel with a StackPanel , then performance will suffer heavily and your application will freeze for large amount of data.
If you think of normal circumstances like arranging two or three controls of your window like this :
<StackPanel Orientation="Horizontal">
<TextBox Text="Hello"/>
<ComboBox Name="cmbItems"/>
</StackPanel>
Then there is no point in using a VirtualizingStackPanel here as there are only 2 controls and there will be no performance enhancement at all. You can replace the StackPanel with a Grid or Canvas too.
You can also think of setting the DataTemplate for the ListBox like this :
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=Item}"/>
<TextBlock Text="{Binding Path=AnotherItem}"/>
</DataTemplate>
</ListBox.ItemTemplate>
Again if you replace it with a VirtualizingStackPanel , it will not have any effect. You can as said above use Grid here too.
Its the ItemsPanelTemplate that you set matters.
So the point is for large amount of data, VirtualizingStackPanel is the correct choice and its by default used in ListBox , ListView and TreeView .
But using VirtualizingStackPanel also has some limitations. You cannot use Grouping and you have set the CanContentScroll of the ScrollViewer to True or else Virtualization will be switched off.
So it also depends on the requirement too. If you want to use Grouping, there is no point in using VirtualizingStackPanel .
Hope I was able to clear your doubt.
People with high attitude deserve the standing ovation of our highest finger!
My Blog![ ^]
modified on Friday, April 15, 2011 3:16 AM
|
|
|
|
|
Tarun.K.S wrote: Actually VirtualizingStackPanel is mainly used to set the
ItemsPanelTemplate for lets take an example for a
ListBox <br /> where large data like 10,000 items or more have to be loaded into it.
This is a bit misleading. You do not need 10,000 items to see the benefits of VirtualizingStackPanel. Even with 200 items you will see a huge difference. If you have a ListView control with 200 items and turn OFF virtualization, your app will consume about an extra 40MB of RAM. Ask me how I know .
|
|
|
|