|
Hi,
I need to display image and text together to the header in the Listview in wpf.Can u please let me know how to implement the same in wpf.
Thanks
|
|
|
|
|
krishnan.s wrote: the header in the Listview
ListView does't have a header.
Are you referring to GridView? If so, you can set the HeaderTemplate on a GridViewColumn.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Ya its the grid view iam referring too . Iam ale to display onlyone at a time , either text or image, Iam not getting how to display both together.Can u please let me know how to display both image and text in the single header cell.
Thanks
|
|
|
|
|
krishnan.s wrote: Iam ale to display onlyone at a time , either text or image, Iam not getting how to display both together
Use a panel that can host more than one element. Here's an example
using a StackPanel:
<ListView x:Name="booksListView" ItemsSource="{Binding Source={StaticResource BooksData}, XPath=*}" >
<ListView.View>
<GridView AllowsColumnReorder="False" >
<GridViewColumn Width="100" DisplayMemberBinding="{Binding XPath=@ISBN}" >
<code><GridViewColumn.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Header Text" />
<Image Source="images/Silverlight_Logo.jpg" />
</StackPanel>
</DataTemplate>
</GridViewColumn.HeaderTemplate></code>
</GridViewColumn>
<GridViewColumn Header="Title" Width="140" DisplayMemberBinding="{Binding XPath=Title}" />
<GridViewColumn Header="Summary" Width="140" DisplayMemberBinding="{Binding XPath=Summary}" />
<GridViewColumn Header="Price" Width="35" DisplayMemberBinding="{Binding XPath=price}" />
<GridViewColumn Header="Stock" Width="35" DisplayMemberBinding="{Binding XPath=@Stock}" />
</GridView>
</ListView.View>
</ListView>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I want to acquire a value for a Source property of XmlDataProvider from application settings.
<settings:Settings x:Key="settings" />
<XmlDataProvider x:Key="srcMenu" Source="{Binding Source={StaticResource settings}, Path = Default.MenuPath, Mode=OneTime}"
XPath="KorepetytorMenu/RootNode"/>
Unfortunately, it comes out that Source is not a dependancy property and thus it cannot be bound.
Any suggestions?
Greetings - Jacek Gajek
|
|
|
|
|
Jacek,
You can assign it to an {x:Static local:AppSettings.MenuPath}. Then in your call using x:Static resolve the value from the settings file.
local above is a reference to your assembly.
AppSettings.MenuPath points to the below code.
Public Class AppSettings
Public Shared Property MenuPath as String
Get
Return (get the application setting and return it)
End Get
End Class
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks for your reply.
I don't get it. I have created that wrapper AppSettings class you mentioned but I cannot get the XAML working.
<XmlDataProvider x:Key="srcMenu" Source="{x:Static local:AppSettings.MenuPath}" XPath="KorepetytorMenu/RootNode"/> That doesn't even compile.
Could you explain it more please? Sorry for my newbie-ness.
Thanks in advance.
Greetings - Jacek Gajek
|
|
|
|
|
Jacek,
Is the MenuPath property Shared (static in C#)
It must be for this syntax to work.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
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.
|
|
|
|