|
Bindings have to have the right source, path, and target.
Don't know what to tell you....I posted a working example...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi
I have a treeview that gets populated with data. This treeview is on a seperate form that opens up when the app loads, from where the user selects something and after clicking okay he/she continues to the main screen. It takes about 20 seconds for the treeview to get filled, and while this is loading I want to display a progressbar. Is there a way to accomplish this with the BackGroundWorker?
Is there perhaps an easier way?
I also had a look at the Circular Progress Bar from one of Sascha Barber's posts on codeproject, if I can get that progress bar animating only when the treeview gets filled, then stopping again, that would also help a lot.
This is just to be fancy, it's not a requirement for the app I'm doing so I don't want to spend too much time with this.
Thanks in advance for any help
|
|
|
|
|
Etienne_123 wrote: s there a way to accomplish this with the BackGroundWorker
Did you have a look at this[^]?
|
|
|
|
|
Etienne_123 wrote: Is there a way to accomplish this with the BackGroundWorker?
Even the BackgroundWorker Class documentation[^] has sample code...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All,
I have a ListView populated from an Access table, with each ListView item displaying infromation with several TextBlocks.
I have also placed a CheckBox and TextBox in each item, to collect data from the user.
On a buton click, I would like to collect the value of the checkbox and textbox, and insert it into another table.
I have done similar things in the past using DataList in ASP1.1, but I cannot get WPF's ListControl to work in the same mannor.
Can somebody please send me some code snippets or point me to some good expamles?
Thanks,
Glyn
|
|
|
|
|
Change your thinking round so that you aren't considering the problem from how you get the data from the interface, as this is the wrong place to do it. Instead, think about using two-way binding to update your model, and save your changes from this.
What I would do is create a model that included a boolean field for the checkbox, and a string field for the textbox. When you bind your listview, set up these fields as binding targets using the standard Text="{Binding Path=..., Mode=TwoWay}" and IsChecked="{Binding Path=..., Mode=TwoWay}" syntax. You now have a simple mechanism for tackling this problem.
"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 your reply Pete.
Could you please explain how to 'wire' this up properly, as I'm struggling!
In the XAML, I set the TextBox text binding to 'TestText'
<TextBox Name="TextBox1" Width="100" Text="{Binding Path=TestText, Mode=TwoWay}"></TextBox>
At the begining of the code behind, I declared and setup TestText:
Private _TestText As String
Public Property TestText() As String
Get
Return _TestText
End Get
Set(ByVal value As String)
_TestText = value
End Set
End Property
To test it, I used the following code to iterate through the ListView.
Private Sub BtnSubmitValues_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles BtnSubmitValues.Click
Dim row As System.Data.DataRowView
For Each row In ListView1.Items
MsgBox(TestText)
Next
End Sub
The test was meant to produce a seperate message box (for each ListView item), containing the value of each TextBox.
The Message boxes were all blank.
What am I doing wrong?
Thanks
|
|
|
|
|
First of all, I'd implement INotifyPropertyChanged on your class if I were you. Raise the property changed notification in your setter.
"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,
I'm still struggling with this.
I posted the same question in another forum, where it was suggested that I use and ObservableCollection.
Which is the easiest method to implement?
Do you have any code snippets, or know of any similar examples?
Thanks
|
|
|
|
|
An ObservableCollection will only tell you that a collection changed (i.e. that items were added or deleted from it). It won't tell you what changed, and it won't tell you if an individual item changed. That's why you implement INotifyPropertyChanged in your classes.
"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 there
i can't simulate a page turn in wpf and 3d environment..
(look like british library)
please help me to do it!
|
|
|
|
|
You could always use this[^].
"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,
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.
|
|
|
|