I'm trying to use the DataForm to display data. The CurrentItem is bound to a property on my ViewModel. The property it is bound to is a simple poco. I've created a custom readonly template. Everything works fine except I can't figure out how to make the DataForm appear "Enabled" or in the Normal state. The data isn't editable, it's displayed as readonly.
The only way I've been able to get it to display in the Normal state was to edit the template and set the Opacity to 100% for the DisabledVisual border.
Is there a better way to do this or use the DataForm for displaying data that isn't editable but still appear enabled?
This fixed it: jedwards14.blogspot.com/2011/02/silerlight-data-forms-with.html. I do have a busy indicator, apparently this is still and issue: silverlight.codeplex.com/workitem/4729
Related
I am making a chat application using XAML in UWP.The side panel is consisting of users. like this.
Everything is in Listbox in which I have this template that consists one ellipse as a circle which is like an indicator,one user image,textblocks and one toggle switch.I have to give states to the toggle switch in on the state it should change the green color of circle and make it red.
I want to give this functionality in code c# in MainPage.cs. I made the object of toggle in toggled Event Handler but I am not able to access the other elements inside the data template like ellispse,textblock.
What is the other alternative way of doing this?
NOTE: It has to be in listbox because I want to use the same template for every user.
The best way to do this would be to use data binding.
You would define a ViewModel class for the item, which would contain a bool property and would react to the toggling of the switch in the setter or have a Command which you would execute when the state event changes using behaviors.
If you really want the code as a event handler on main page, you have some options. To get the item associated with the toggle, you can use its DataContext property and cast it to the data type you are using. Alternatively, you can use Visual Tree Extesnions provided by the UWP Community Toolkit. This enables you to find the parent (probably Grid) where you store all the item controls and then manually find the user image, TextBlock, etc.
Is it possible to change the "default" forecolor of a label?
I know I can change each control one-by-one in either design time or run time but I wonder if there is a better way.
I can do this at run time
lblCompanyName.ForeColor = color.darkblue
I could also have a loop to look at all of my controls on the form and change them in one small bit of code, but there must still be a better way.
I see at design time that the "default" label forecolor is "ControlText" so can I change ControlText perhaps to equal color.darkblue and then all of my labels will be dark blue without needing to code it one control at a time (or within a loop).
Thankyou
David.
You can't change it for a standard Label control but you can always create your own class that inherits Label and then sets the ForeColor property in the constructor. You would then use that control instead of a Label.
EDIT:
If you want to change the text colour for all your Label controls at run time then you should use a bound application setting. On the Settings page of the project properties, add a setting of type Color with User scope and name it LabelForeColor or something else if you prefer. Now, select a Label in the designer, open the Properties window and use the (ApplicationSettings) -> (PropertyBindings) node to bind the ForeColor property to the setting you created.
You can then access that setting in code via My.Settings.LabelForeColor and any Label bound to it will be updated automatically. You can bind as many different Label controls on as many different forms as you like. You can only bind one at a time though, so I would recommend copying and pasting an existing bound Label rather than adding a new one each time. If you have existing Label controls and you're confident enough, you can copy, paste and edit the binding code in the designer code file(s).
There's really no point your using a custom control in this case because the setting will control each control anyway. No matter what value you set in the constructor, it will still be set by the bound setting afterwards. Note that any change you make to a setting will be automatically saved at shutdown and reloaded at startup.
I want to write an AutomationPeer for my custom control in WPF.
Now, I want to show textBlocks \ TextBoxex that are not actually visible on my control.
I know how to override the method GetChildrenCore().
My problem is that when i run the playback (coded ui record) - it's trying to find a control not vissible on the window. Have you got any ideas?
You can set the SearchConfiguration VisibleOnly on the Coded UI control. Also, the UITestControl.FindMatchingControls method can let you know if the search properties are too ambiguous. Coded UI stops looking for a control after the first instance of a matching control is found.
inspect.exe can shed light on a form and how Coded UI may be seeing the control.
Try opening the Designer.cs and see the hierarchy and what Coded UI is trying to find.
I use the VisualStateManager-Element to re-locate some XAML-elements on my page based on the current Visual State.
My problem is that I use a gridview which has to become a listview when the window is snapped (because of the small horizontal space left). I bound some other elements to the gridview's selectedItem property. My first approach was to create a listview and show/hide it based on the visual state. I would need to update the binding of my other elements as well though ( from gridView.selectedItem to listView.selectedItem) which is apparently impossible in the visualstatemanager. Another possibility would be to change the binding from code behind.
Are there other solutions (preferably in XAML)?
I think the generally accepted answer would be that you should have a piece of xaml per visual state. You collapse the one that is not currently in use. You would only make changes or create bindings manually if you were going to do something that required a dynamic number of bindings or something similar. In this case you have a fixed set of bindings to a known set of UI elements, so you would simply setup all the bindings in xaml.
I am trying to add datagridview control in my custom control but i failed.
I started creating new project[windows custom control library], added datagridview control on it and also added a property naming "DGVMain" which refers to datagridview control.
I compiled it.
While testing i find its properties like visible and other working but when i click on columns property it doesn't work. i.e i cannot add/edit columns into the datagridview of my custom control.
Did i miss any steps or do i need to add some more actions?
As you don't have other control within your custom control, maybe an inherited user control would be more appropriate in this case and I'm sure it will also fix your problem.