|
*cough* technology guinea pigs *cough*
Our thoughts are with you.
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist
|
|
|
|
|
Hi
I have a rather simple question. If I declare a ModelVisual3D as a resource in XAML, how can I use this resource in multiple places without getting the error " Specified Visual is already a child of another Visual or the root of a CompositionTarget" ?
|
|
|
|
|
In your resource file, use the Shared attribute so your resource gets cloned each time you use it.
For example:
<ModelVisual3D x:Shared="False" ...>
...
</ModelVisual3D>
|
|
|
|
|
I can't access this attribute at all?? I tried "Shared, x:Shared, isShared" and none of them exist. Do I have to reference something specific first?
|
|
|
|
|
This only works if your item is defined in a ResourceDictionary.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Make sure you have referenced this namespace:
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
Okay thanks I got it working.
For some or other reason x:Shared doesn't show up in intellisense, but it still works.
|
|
|
|
|
Hi,
I am trying to implement upload images to database by using a WCF service.First I placed a opendialogbox in the silverlight page and I am planning to to pass the file path to the WCF service and there I will convert it to binary format and save it in the database. Here my problem is, I am unable to get the openfile dialog file complete path due to security reason in silver light and in WCF service I an not even getting open dialog control.
If anyone have idea to get the complete path of the selected file in open file dialog please reply me.
Thanks in advance.
|
|
|
|
|
You can't get the complete path because this would represent a security hole in the system. It's the same reason that you don't get the path in the standard file upload component in ASP.NET. By giving access to this, you could present a malicious author with knowledge about your file system.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Read file as stream from openFileDialog.File from the client and send it to the WCF Service.From the WCF Service write the stream in server and save that path in database.
|
|
|
|
|
Hi,
I developed a Usercontrol which has a slidercontrol and the textbox displaying the current slider value.
I need to adjust only the slider width from the widow XAML that uses the Usercontrol . Can anyone let me know how to achieve this.
Thanks
|
|
|
|
|
Hi...
An example in the Codeproject has this implementation.
I am extracting from it and pasting it here.
in XAML.cs,
<pre> private void CenteringSlider_LostMouseCapture(object sender, MouseEventArgs e)
{
// change the size of the ellipse when slider value is change
// for this example the slider max is 80
// and the slider min is -80
PlumEllipse.Width = PlumEllipse.Height = (100 + e.NewValue);
}
private void CenteringSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
// set a 500ms duration
Duration returnToCenterDuration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
CenteringSlider.BeginAnimation(Slider.ValueProperty,
new DoubleAnimation(CenteringSlider.Value, 0, returnToCenterDuration, FillBehavior.Stop));
// set the slider value to zero
// otherwise the slider will return to the last postion after the animation
CenteringSlider.Value = 0;
}
</pre>
Please search for the full project in codeproject itself.
Thank you,
Ramm
|
|
|
|
|
Assuming you have exposed a property in your usercontrol for the width, all you need to do in the control itself is add Width="{Binding MyWidthProperty}" in the XAML for the slider. Then, the hosting item just sets MyWidthProperty="nnn" (where nnn is the width you want).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks for the reply , should i expose the width as the dependency property.
One more question, if i need to modify other properties like Height, MinWidth,MinHeight then should i register those properties also as a dependency property in the user control.
Thanks
|
|
|
|
|
Yes and yes.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I am looking for a variation of this answer as well (assuming I read the question right).
I have a simple UserControl that has 3 controls which I plan to use to standardise the visual look. The only part of this control that will very is the text on the button. I would like to be able to set this within the XAML as once set it will not change.
For example, i would like to be able to do something like this.
<Views:CurrentStatusView ButtonText="Proceed"/>
If I expose a property I am able to set the value, but how do I use this within the user control, I have tried Binding, setting the value in the constructor etc with no success.
Many thanks
Just racking up the postings
modified on Thursday, September 3, 2009 10:26 AM
|
|
|
|
|
Here's a sample that shows how to do this (first of all, the XAML):
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="WpfSample.CurrentStatusView"
x:Name="UserControl"
d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<Button HorizontalAlignment="Left" VerticalAlignment="Top" Content="{Binding ButtonText}"/>
</Grid>
</UserControl> then the code behind
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
namespace WpfSample
{
public partial class CurrentStatusView : UserControl
{
public CurrentStatusView()
{
this.InitializeComponent();
ButtonText = "Hello there";
DataContext = this;
}
public static DependencyProperty ButtonTextProperty =
DependencyProperty.Register(
"ButtonText",
typeof(string),
typeof(CurrentStatusView));
public string ButtonText
{
get { return GetValue(ButtonTextProperty).ToString(); }
set { SetValue(ButtonTextProperty, value); }
}
}
} Finally, you set it with:
<WpfSample:CurrentStatusView ButtonText="Howdy" HorizontalAlignment="Left" Margin="27,42,0,0" VerticalAlignment="Top" />
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
|
Obviously you are trying to swallow more than you can chew.
You really do need to spend a minimum time learning the little tiny block of which a WPF application is made.
Stress to your boss that you need a learning phase (such as 1 week reading CP articles and experimenting) and it's not wasted as you are just unable to be productive yet!
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.
|
|
|
|
|
The answer to this question will also answer a more general question I've had that I haven't been able to figure out. The more general question is, how do I address a WPF object in my assembly from a Uri object? This would be so useful but I've never been able to figure out how to do it. So answer the specific question and a whole new world will open up for me. I think the answer is going to involve some use of the UriKind.Relative value as the second parameter in the Uri constructor but I don't know how to express the first parameter in the constructor.
Say I have a Window object in my assembly called TextWindow. I want to pop up TextWindow by clicking on a WPF Hyperlink object within a Paragraph. What would the XAML look like? Something like:
<Paragraph>
<Hyperlink
NavigateUri="???TextWindow???"
>
My Hyperlink Title
</Hyperlink>
</Paragraph>
What would I replace the "???" strings with to make this work? I know it's easy to do stuff like this in WPF, but I'm surely not very good at reading the documentation to find the answer.
|
|
|
|
|
I guess the lack of response stemmed from the incoherence of my question. It was based on a misunderstanding of what Hyperlink.NavigateUri is all about. It does not apply to the Window class but to the Page class. Also, in my application, it is more appropriate to place the Hyperlink object inside of a TextBlock, not a Paragraph. So my XAML ended up looking like this:
<TextBlock
Margin="0,5,0,0"
>
<Hyperlink NavigateUri="TutorialOverviewOfPhotoShowsPage.xaml">
Overview of Photo Shows
</Hyperlink>
</TextBlock>
Sometimes it helps to ask a question in a forum because it forces you to articulate the problem. Even if your articulation isn't entirely coherent, it gets you thinking more deeply about the problem you are trying to solve. I hope I didn't offend anyone by cluttering up the forum with a question that did not make any sense.
However, I'm not sure I learned how to code my larger issue. I don't think I stated that coherently, either.
|
|
|
|
|
I've a webservice that returns a TList object and populates the datagrid as follow:
void proxy_CustomerInfoCompleted(object sender, CustomerInfo.CustomerInfoCompletedEventArgs e)
{
datagrid1.ItemsSource = e.Result;
}
It works, but now, what I need to do is to create a local TList copy of the e.result and then bind the newly created object to the datagrid. Is it possible to do it in C#?
Something like:
TList<Customer> = e.Result;
datagrid1.ItemsSource = Customer;
|
|
|
|
|
What is a TList?
e.Result is apparently already a reference to "a local TList copy"
so can't you just assign it to a variable?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That is my point exactly!
e.Result is the object that is returned from the Web Service. It is a TList object. But how do I copy it to a local TList object?
|
|
|
|
|
TList mytlist = e.Result as TList;
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|