|
Maybe this is a simple question...
I created a search control in WPF. I then placed it on a view. Since the view doesn't know about the user control, how can it get data off of it, or make calls into it.
I tried using a messenger, but when there is more than one instance of the user control running, they al get the message.
What's the right way to do this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Maxx wrote an article where his messages have a destination that consumes the message and it does not propagate further.
Just off the top of my head I would create a search interface on each VM that handles the interaction and pass the VM to the search VM onnavigateto of the view.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks
Can you point me to the article?
If it's not broken, fix it until it is
|
|
|
|
|
Bastards got 3 Xs[^] and underscores in his name, amazing what the mind thinks it sees
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Sorry about the XXX and _
It was originally underscore free but I had some hassle with the account and creatged a new one - and it wouldn't let me use Maxxx.
I actually wanted to use .\\axxx but it wouldn't let me do that either
Thanks for referring to my article, BTW
|
|
|
|
|
Not quite sure an "e.Handled = true" concept in messenger makes sense since the messages are going to be propogated in a random/arbitrary/indeterminate order. Its really up to the subscriber to determine if the message should be handled. Your "e.Handled = true" concept might just mean that somebody handled it and its up to the subcriber to play nice and check the flag. A lot of messenger implementations fire & forget the notifications in async mode too. Then it makes even less sense.
|
|
|
|
|
I'm afraid I subscribe to fire and forget school and have not implemented the Handled concept. I do have trouble defining the boundaries of where a message should be used!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Now that I'v had a few days to thin about it, the subscriber should pass in it's id to the control Init. Could be a PK or a guid. If there are 3 tabs open, each instance of control would be intiailized with a different id.
Then, each subsequent call would have that Id passed with it. Then control's methods would only act if the Id passed in the message matches that sent in the 'init' method.
If it's not broken, fix it until it is
|
|
|
|
|
That's about how I would do it - although pass a reference to the object rather than just an Id - you then have the advantage of being able to access the object in question from your consumer.
Send Message - "I've just updated this Customer"
Receive Message - do nothing - not interested in this customer
Receive Message - update my list of customers as the value in the CustomerType property matches my filtering criteria.
Receive Message - I'm displaying this actual customer - so I'll refresh myself
the 'handled' approach can be useful; my example is selecting a customer to edit from a list.
If an existing customer edit view is out there, in a 'clean' state, it can take over the job of editing the selected customer - but you don't want another view to do the same thing too!
|
|
|
|
|
Hello,
I have a tab control with two tabs in it,in each tab i have text boxes, the data of the text boxes is being validated using the IDataErrorInfo interface.
If there is an invalid data i am rendering a red ellipsis and a tool tip box using this XAML code:
<ControlTemplate x:Key="TextBoxErrorTemplate">
<DockPanel>
<Ellipse DockPanel.Dock="Right" Margin="2,0" ToolTip="Contains invalid data" Width="10" Height="10" >
<Ellipse.Fill>
<LinearGradientBrush>
<GradientStop Color="#11FF1111" Offset="0" />
<GradientStop Color="#FFFF0000" Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<AdornedElementPlaceholder />
</DockPanel>
</ControlTemplate>
Text box XAML:
<TextBox.Text>
<Binding Path="ID" UpdateSourceTrigger="PropertyChanged"> <Binding.ValidationRules> <DataErrorValidationRule/> </Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
The problem is when i go to another tab and then come back again the red Ellipses are disappear.
Help any one?
Thanks
|
|
|
|
|
On Tab selection change event, give the datacontext to the textboxes.
Say for example for first tab, you have 3 textboxes in a grid and you provide the class object to be bound as datacontext of the grid; when you select that tab, again give the same object as datacontext to the grid.
grid.Datacontext = myClassObject;
Please see if this works for you.
|
|
|
|
|
Hey,
No it doesn't work.
The problem is when i switch to another tab and the come back the red Ellipsis disappear.
Thanks.
|
|
|
|
|
Hi!
I have been looking for a way to extend the default printdialog in PresentationFramework. I need to filter the available printers some how. Does anyone know if it is possible either to filter the printer queue datasource or to extend the dialog to add such functionallity?
Andreas Johansson
Senior Software developer at Tieto Sweden
|
|
|
|
|
|
Thank you for your reply.
I have already found those articles and posts but they all work with the windows forms version of the printDialog. I cant figure out how to apply the technique to the presentationframework PrintDialog.
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
Well, there is always the option of constructing a completely new PrintFile dialog in WPF from scratch, but that seems like a lot of work..
|
|
|
|
|
I know
Looks like thats my only way out.
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
Hi i am writing an application that has WPF as its front end and a Windows service which is responsible for scheduling and executing the my operations.
At the moment i use WCF to send live progress messages to the client from the service and i add this message to a listbox on the WPF listbox using the items.add function from the code behind, But the performance is very poor. I need help or suggestions on the best way to display this messages efficiently.
|
|
|
|
|
What sort of volume and why do you consider performance poor. You have described the standard architecture for a monitoring app!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I would bind a property containing the messages, perhaps a subset of messages, to a multiline textbox.
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
Good Day
i have buttons and i have defined them like this
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Stretch" Orientation="Horizontal" Height="400">
<k:KinectTileButton Background="{x:Null}" BorderBrush="{x:Null}" Style="{x:Null}" x:Name="btnA" Click="btnA_Click" MinHeight="400" MinWidth="350" Width="198" >
<Image Source="../Images/A.png" />
</k:KinectTileButton>
<k:KinectTileButton Background="{x:Null}" Style="{x:Null}" BorderBrush="{x:Null}" MinHeight="400" MinWidth="350" Width="198" x:Name="btnB" Click="btnB_Click" >
<Image Source="/SchoolPlay1;component/Alphabets101/Images/B.png" />
</k:KinectTileButton>
<k:KinectTileButton Background="{x:Null}" Style="{x:Null}" BorderBrush="{x:Null}" x:Name="btnc" Click="btnC_Click" MinHeight="400" MinWidth="350" Width="198" >
<Image Source="/SchoolPlay1;component/Alphabets101/Images/C.png" />
</k:KinectTileButton>
</StackPanel>
</Grid>
and m gridlayout has the following properties
<Grid x:Name="LayoutRoot" MinHeight="768" MinWidth="1024" >
and my Page does not have with and height set as i want to cater for different resolutions.
if i remove the stackPanel , my buttons bring big nicely , but i need then in a Stackpanel kind of control so that they will be aligned in order , but when i have the stack panel in the , the buttons become small, can anyone help regarding this, below is the example of the image
Image Example[^]
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
Hi Viswa,
Why do you need to use a StackPanel? Generally if you have a fixed layout panel, go with Grid.
But anyways, I dont know exactly how KinectTileButton works, but if you specify same size for MaxWidth and MinWidth, or MaxHeight and MinHeight, everything will remain same irrespective of the container.
Do let me know if you are looking for something else.
|
|
|
|
|
hi Abhishek
i resolved the issue by using a Uniform.
Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|
|
You mean UniformGrid right.
Anyways, good to hear that.
|
|
|
|
|
Correct Thanks
Vuyiswa Maseko,
Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa[at]dotnetfunda.com
http://www.Dotnetfunda.com
|
|
|
|