|
Hi,
Please by using anything if it works thats fine for me, its taking lot of time to resolve this bug than creating really something.
I dont know what to do its effecting my SLAs
Thanks,
Abdul
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
|
|
|
|
|
Hi
I have a class library with code that is compatible with both Silverlight and standard .net libraries. (the minor incompatibilities can be solved with #if)
How I can compile the code for both of these platforms? I mean - how do I set up Visual Studio to have two output configurations - one for .net, one for silverlight, so that my bin folder will contain two compiled .dlls?
The project was initially created as Widnows Class Library and now I don't even know how to tell the VS to use Silverlight libraries to begin with
|
|
|
|
|
|
I want to create a control and use its size as data input from user. So adjust the control size by user's mouse is required, just like what we do to the window? Is there any existing property we can set to do this in WPF ?
|
|
|
|
|
Here[^] is an excellent article on how to move and reshape controls in your app.
Good Luck!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thank you ! That's exactly what I want !
|
|
|
|
|
No Problem
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I have styled a list so that the list items appear as hyperlinks. Here's my xaml:
<UserControl.Resources>
<converters:ProjectTypeImageValueConverter x:Key="projectTypeConverter"/>
<!--This is the template for the Recent projects list items-->
<DataTemplate DataType="{x:Type local:RecentProjectModel}">
<StackPanel Orientation="Horizontal"
Margin="2">
<Image Source="{Binding ProjectType, Converter={StaticResource projectTypeConverter}}"
Margin="0,0,5,0"/>
<TextBlock Width="150">
<Hyperlink Foreground="RoyalBlue">
<TextBlock Text="{Binding Caption}"/>
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
and
<ListBox x:Name="lstRecent"
Grid.Row="1"
Grid.Column="0"
ItemsSource="{Binding RecentProjects}"
SelectedItem="{Binding SelectedRecentProject}"
BorderThickness="0"
Margin="3"
MinWidth="235"/>
When I click the link, the SelectedRecentProject is not set. If I click the image of the list item, it is set. How do I set the SelectedRecentProject when the link is clicked?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
It doesn't work. No response.
Everything makes sense in someone's mind
|
|
|
|
|
Wow, I had to write a quick sample app for this one. The Hyperlink / TextBlock combo is eating the mouse down. You'll notice that the selection changed event never gets fired. You can set IsHitTestVisible="False" on the TextBlock (but you will lose the hand cursor)... or you need to derive a "HyperlinkEx" class from Hyperlink and set the focus to the parent yourself, or you can change controls to something else . If you are OK with losing the hand cursor when they mouse over the link, the the IsHitTestVisible="False" is the quickest fix.
EDIT: actually, you probably need to do the derived class thing on TextBlock since Hyperlink isn't a UI element. Just derive a class from TextBlock and override PreviewMouseLeftButtonDown and chase up the visual tree til you hit the ListBoxItem. I whipped this out in a few seconds and it works without losing the hand cursor. I'll leave the clean up / error checking to you .
public class TextBlockEx : TextBlock
{
public TextBlockEx()
: base()
{
this.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(HyperlinkEx_PreviewMouseLeftButtonDown);
//this.MouseLeftButtonDown += new MouseButtonEventHandler(HyperlinkEx_MouseLeftButtonDown);
}
void HyperlinkEx_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
object v = this;
while (v != null)
{
if (v is ListBoxItem)
{
((ListBoxItem)v).IsSelected = true;
((ListBoxItem)v).Focus();
break;
}
v = VisualTreeHelper.GetParent((DependencyObject)v);
}
e.Handled = true;
}
}
|
|
|
|
|
ya, that did it. I'll deal with the cursor some other time. It's not that big of a deal right now.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
I edited the message as you responded... I've got the "TextBlockEx" working for you... just needs a bit of clean up and doesn't lose the mouse cursor .
|
|
|
|
|
Excellent. I'll throw it in later today
Many thanks
Everything makes sense in someone's mind
|
|
|
|
|
This worked perfectly. Thank you!!!
Everything makes sense in someone's mind
|
|
|
|
|
I have this data template
<UserControl.Resources>
<!--
<DataTemplate DataType="{x:Type local:RecentProjectModel}">
<StackPanel Orientation="Horizontal">
<Image Source="/...;component/Media/Graphics/abtech_triangle_blue_small.png"
Margin="0,0,5,0"/>
<TextBlock Width="150">
<Hyperlink>
<TextBlock Text="{Binding Caption}"/>
</Hyperlink>
</TextBlock>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
I would like to change the image based off the value of a property called ProjectType on the RecentProjectModel class.
How do I do this?
Thanks
Everything makes sense in someone's mind
modified 24-Oct-11 13:44pm.
|
|
|
|
|
Just bind to ProjectType and use a value converter, or have your VM expose an ImageSource property and bind to that directly. Is your binding to Caption working? I seem to recall there are some issues when using binding inside of a data template, but I can't recall off the top of my head.
|
|
|
|
|
Yes the caption is working.
Never used a converter before. Got an exmaple?
Everything makes sense in someone's mind
|
|
|
|
|
|
Ok I see.
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
That worked perfect - thanks
Everything makes sense in someone's mind
|
|
|
|
|
I want to "next" a child view inside a parent view. The child view will be removed from time to time and replace with other views.
How does the parent view know what child views properties change?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
Views shouldn't really know about each other in MVVM. They typically communicate via a messenger type service so there is a complete disconnect. If the parent view is going to hold a reference to the child view, you can just use the views INPC implementation (since have it already).
|
|
|
|
|
Well, in summary, what I'm hoping to do is get some kind of notification in the parent ViewModel that a property in the child ViewModel has changed.
What about binding? Any way to do this?
Everything makes sense in someone's mind
|
|
|
|
|
How are you creating the child views? In my apps, I never create the VM directly, I just load the window.xaml and that uses a view locator service to instantiate the VM and wire it up.
Another question is how many properties are going to be changing and how often. If we are talking about 2 or 3 properties that will change 2 or 3 times then my answer would be different then if 50 properties were changing 1000s of times.
With the low prop count / low change count, you can use messenger as I mentioned below.
Also, do you care what property is changing? Or do you just want to know that the view is dirty? etc?
If the parent needs to know whenever 1 of 50 properties change and its new value, etc. I'd probably just have the child view use messenger to send open / close messages so the parent can sub to the INPC events in the child using weak events or something like that.
Again, all depends on how much you need to know about the property that changed and how often they are changing, but I threw out a bunch of options for you .
|
|
|
|
|
You can pass an Action delegate from the parent view to the child view.
Whenever the property within the child changes, fire the Action and let the parent method (pointed to by this action) execute.
|
|
|
|