|
I know that. The problem was another: the Source property is of Uri type not String .
public static class AppSettings
{
public static Uri MenuPath
{
get
{
return new Uri(Settings.Default.MenuPath, UriKind.Relative);
}
}
}
I wonder why it doesn't allow using directly Settings.Default.MenuPath (with a proper String -> Uri converter). The Default property is static as well.
Greetings - Jacek Gajek
|
|
|
|
|
I played with this some more and got the same results.
Suggest setting in code, reading the file location from the settings and setting the Source on load.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl Shifflett wrote: setting in code
This is what I always can do. I'm learning WPF and more I want to achieve more and more tedious and exasperating it becomes.
Thanks for help though.
Greetings - Jacek Gajek
|
|
|
|
|
Hey.
In our application we host d3d content in a WPF application and use d3dimage. However, sometimes we want to use a reference device that comes with the SDK to render the content in software. The problem is that the content is not displayed in the d3dimage (the content IS rendered.. getting the pixels from the render target and saving them to a file shows the content we want to render clearly).
Has anybody encountered this problem? Is there any known solution?
Alex.
|
|
|
|
|
Hi,
I have been experiencing one typical problem in MVVM implementation in WPF based XBAP application. If anyone can through some light then it would be great help for me. As I am reaching to deadline of project and this (V to VM) communication seems to be biggest trouble for me. I have looked several articles and samples over the Internet but nothing seems to be helpfull for me.
My Requirement
I have a Main view (XAML page), this page contains one tab control having four tab items and each tab item has a grid control (we are using Xceed grid).
Let me explain this situation more precisely-
I have a view (Name EmployeeView), this view is nothing but a XAML page. In this view I have a tab control (Name EmploeeInfo). This tab control has four tab items (Name PersonalInfo, ProfessionalInfo, SocialInfo and FinancialInfo). Each tab item has one grid (Xceed grid- a .NOT compatible third party control) where I have to display the respective information.
I have created one user control (XAML page) for each tab and placed all user controls in EmployeeView, so this way I have total 5 views (one EmployeeView which is my main view and four for user controls), I also have 5 ViewModels (one for EmployeeView which is my MainViewModel and four for user controls)
I hope I have made myself clear in explaining the situation.
My Problem
I have to load the respective data only when the user clicks on the associated tab item i.e. I want to fetch personal information from model only when user clicks on PersonalInfo tab item, and want to fetch Social information from model when user clicks on SocialInfo tab item and so on...
I created ICommand in each ViewModel and bind that ICommand in respective view, now if I create instance of each ViewModel in MainViewModel then all tabls load data when the page loads, if I do not do not instantiate the all ViewModels in MainViewModel and instantiate them on-demand when they are clicked then my ViewModel gets data from Model but View does not get refershed to display the data, in this case all four tabs remain blank.
I have looked into many sampes but all samples load data initially but I want it on-demand....
If anyone can show me the way to solve this problem then it would be a great help for me.....
Thanks in advance.
Regards
Vinod
|
|
|
|
|
As per my understanding, your problem has nothing to do with MVVM. You have a databinding problem. If databinding object sources have data then there is no reason the View would not display them. Look at it from a simple perspective, if your object has data and it is not showing up in the UI then the first thing you should do is ensure databinding is happening properly. Check the Output window to see the databinding errors logged. Take a look at this article[^]
|
|
|
|
|
Hi,
Thanks a lot for your response. As per your response I have checked the binding information, everything looks fine from binding perspective.
The reason of my problem is that I always find the handler null, so my OnpropertyChanged() method doesn't get called henece the data is not refreshed in view.
Please let me know if I am missing anything?
Thank you very much
REgards
Vinod
|
|
|
|
|
hello
request.responseJSON.d - what's ".d" in the end? I don't know what I've done but response JSON used to have this ".d" postfix, now it disappeared.
Thanks
dev
|
|
|
|
|
Have a read of this[^] article.
"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
|
|
|
|
|
That's a good one, many thanks.
dev
|
|
|
|
|
You're welcome.
"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
|
|
|
|
|
hi friends..
Currently i am developing wpf application using mvvm pattern.
I have one textbox in which user enters his username and another passwordbox in which he enters password.
Now what i want, after entering password when user press enter then LoginCommand which is binded with LoginButton will be fire..
This thing will be done if i wrote keypress event on codebehind..but i am using mvvm pattern so how to handle this in viewmodel??
Thanks a lot..
|
|
|
|
|
First of all, you don't have to get completely hung up on the View having no code behind it, in MVVM - it's a convention, not a hard and fast rule. Secondly, you should set your login button to be the default button using IsDefault="true" in the button attributes; this will trigger the Command behind the button on an Enter press.
"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 a lot..
IsDefault=true works for me..
|
|
|
|
|
You're welcome.
"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
|
|
|
|
|
Hi All,
i have a big problem with my wpf C# application, that is when i set Height and width to Polygon shape it comes as cut shape
how can avoid this problem
Thanks
Vineeth
|
|
|
|
|
If you place it in a grid and resize the grid, it should maintain shape as long as your resize porportionally.
You can also place it in a ViewBox to handle resizing.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi Karl,
Thanks for reply
but i have some other problems occur when i place in viewBox or Grid, it is a Vector editing Application that have 2 type selection, first one is Direct Selection that helps for Standard resizing(Height and Width) next is Node selection that helps for Node editing (Drag and change the polygon points using a Adorner Thumb), when i place the polygon in a viewbox i cant do Node Editing, so please check this sample and give a reply
Thanks
Vineeth
<Window x:Class="SampleApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Sample" Height="600" Width="922" WindowState="Maximized" Loaded="Window_Loaded">
<Grid>
<Canvas Name="myCanvas" Background="AliceBlue">
<Polygon Name="polygonFill" Stretch="Fill" Points="177,177 0,177 88.5,0" Fill="Transparent" Stroke="Black" StrokeThickness="2" Canvas.Left="100" Canvas.Top="100"
Height="{Binding ElementName=sliderStretchFill,Path=Value}"
/>
<Slider Name="sliderStretchFill" Width="150" Height="22" Canvas.Left="112" Canvas.Top="35" Minimum="10" Maximum="200" Value="100" />
<Label Canvas.Left="100" Canvas.Top="66" Height="28" Name="lblStretchFill" Width="77">Stretch="Fill"</Label>
<Label Canvas.Left="175" Canvas.Top="66" >Height=</Label>
<Label Canvas.Left="215" Canvas.Top="66" Height="28" Name="lblStretchHeight" Width="29" Content="{Binding ElementName=sliderStretchFill,Path=Value}"/>
<Polygon Name="polygonNone" Stretch="None" Points="177,177 0,177 88.5,0" Fill="Transparent" Stroke="Black" StrokeThickness="2" Canvas.Left="700" Canvas.Top="100"
Height="{Binding ElementName=sliderStretchNone,Path=Value}"
/>
<Slider Name="sliderStretchNone" Width="150" Height="22" Canvas.Left="712" Canvas.Top="35" Minimum="10" Maximum="200" Value="100" />
<Label Canvas.Left="700" Canvas.Top="66" Height="28" Name="lblStretchNone" Width="91">Stretch="None"</Label>
<Label Canvas.Left="785" Canvas.Top="66" >Height=</Label>
<Label Canvas.Left="825" Canvas.Top="66" Height="28" Name="lblStretchNoneHeight" Width="29" Content="{Binding ElementName=sliderStretchNone,Path=Value}"/>
</Canvas>
</Grid>
</Window>
namespace SampleApplication
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
Selection selection;
AdornerLayer adornerLayer;
void AddAdornerLayerToPolygonFill()
{
adornerLayer = AdornerLayer.GetAdornerLayer(polygonFill);
selection = new Selection(polygonFill);
adornerLayer.Add(selection);
}
void AddAdornerLayerToPolygonNone()
{
adornerLayer = AdornerLayer.GetAdornerLayer(polygonNone);
selection = new Selection(polygonNone);
adornerLayer.Add(selection);
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
AddAdornerLayerToPolygonFill();
AddAdornerLayerToPolygonNone();
}
}
}
namespace SampleApplication
{
class Selection : Adorner
{
VisualCollection visualChildren;
Polygon polygon;
Point point;
ArrayList thumbArrray = new ArrayList();
Thumb thumb;
public Selection(UIElement adornedElement)
: base(adornedElement)
{
visualChildren = new VisualCollection(this);
polygon = (Polygon)adornedElement;
for (int i = 0; i < polygon.Points.Count; i++)
{
point = polygon.Points[i];
thumb = new Thumb();
BuildCorner(ref thumb, Cursors.SizeNESW);
thumb.Tag = i;
thumb.DragDelta += new DragDeltaEventHandler(thumb_DragDelta);
thumbArrray.Add(thumb);
}
}
void thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
polygon = (Polygon)adornedElement;
thumb = (Thumb)sender;
point = polygon.Points[(int)thumb.Tag];
point.X += e.HorizontalChange;
point.Y += e.VerticalChange;
polygon.Points[(int)thumb.Tag] = point;
adornedElement = polygon;
InvalidateArrange();
}
void BuildCorner(ref Thumb cornerThumb, Cursor customizedCursor)
{
cornerThumb = new Thumb();
cornerThumb.Height = cornerThumb.Width = 10;
cornerThumb.Background = Brushes.Black;
cornerThumb.Cursor = customizedCursor;
cornerThumb.Opacity = 0.80;
visualChildren.Add(cornerThumb);
}
protected override Size ArrangeOverride(Size finalSize)
{
FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
polygon = (Polygon)adornedElement;
for (int i = 0; i < polygon.Points.Count; i++)
{
point = polygon.Points[i];
thumb = (Thumb)thumbArrray[i];
thumb.Arrange(new Rect(point.X - 5, point.Y - 5, 10, 10));
}
return finalSize;
}
protected override Visual GetVisualChild(int index) { return visualChildren[index]; }
protected override int VisualChildrenCount { get { return visualChildren.Count; } }
}
}
|
|
|
|
|
I don't get what the problem is.
If you want the poly to maintain shape, shouldn't you have to change the height and width together?
When I changed the height, I got the expected behavior.
Sorry I'm not understanding.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi,
thanks for your reply
First change the height then change each point using adorner Thumb that added to the shape to reproduce the issue
Thanks
|
|
|
|
|
Hi
I am working on WPF and I need to place a Datagrid in this page for displaying the table data. But I found that in WPF we will not have Datagrid. But how can I do this.
If anyone have any idea to get the datagrid in WPF, please reply me.
Thanks in advance.
|
|
|
|
|
There a microsoft one on Codeplex or a free one from Xceed
|
|
|
|
|
Hi , there are many ways to do it
a) You can get one from codeplex
b) Infragistics control [ I am using this in my current project ]
c) You can use a List box in place of a grid.
d) Make google search for more information
Hope this helps
Niladri Biswas
|
|
|
|
|
I was wondering if anyone knew how I can give the user the ability to move an image element. Basically, I want to be able to allow the user to drag the image over a listbox and have a drop effect. Below is my xaml code:
<StackPanel Grid.Row="0">
<Border CornerRadius="4" Background="LightYellow" BorderBrush="Black" BorderThickness="2">
<Label x:Name="location" HorizontalAlignment="Center" Height="30" FontSize="12" VerticalAlignment="Center">Person Information</Label>
</Border>
<Image Width="150" Height="150" Margin="5" PreviewMouseLeftButtonDown="gridImage_PreviewMouseLeftButtonDown" PreviewMouseMove="gridImage_PreviewMouseMove" x:Name="gridImage" >
Image.RenderTransform>
<TranslateTransform x:Name="imgTranslate" X="0" Y="0" />
</Image.RenderTransform>
</Image>
</StackPanel>
I'm currently using the PreviewMouseLeftButton and PreviewMouseMove buttons to create a drop effect and this works fine; but I would like to make it more animated to where the user is actually dragging the image. Thanks.
Terrance C.
modified on Wednesday, June 3, 2009 11:37 AM
|
|
|
|
|
Check out Josh Smith's article on WPF Drag & Drop here on Code Project.
modified 27-Feb-21 21:01pm.
|
|
|
|