VSPackage theme-colored - xaml

I built a VSPackage for VS2015. How can I get the current theme colors to color my elements appropriate? I tried things like
xmlns:vsfx="clr-namespace:Microsoft.VisualStudio.Shell;assembly=Microsoft.VisualStudio.Shell.14.0"
Background="{DynamicResource {x:Static vsfx:VsBrushes.CommandBarOptionsBackgroundKey}}"
But that didn't work.
Any help appreciated.
Thanks!

This worked for me:
xmlns:vs_shell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
Background="{DynamicResource {x:Static vs_shell:EnvironmentColors.CommandBarMenuBackgroundGradientBrushKey}}"
You can get the full list of colors here: Microsoft.VisualStudio.PlatformUI.EnvironmentColors

Related

Is it possible to make the background-colour of a Canvas field dependent on its value?

I want one datetime field's background colour to depend on its value. Like if a certain date is passed, the background changes to red.
Is there a way to make this in XAML?
I know there is no possibility of an "if" condition/instruction, but maybe you guys found some way to implement a similar function.
<Canvas Canvas.Left="893" Canvas.Top="208" Height="25" Width="99" Background="red" Panel.ZIndex="-1"/>
<assembly:FieldControl Canvas.Left="890" Canvas.Top="206" FieldControlType="DateControl" FormField="{x:Null}" Height="25" LabelColumnWidth="0" Refnr="123456789" ShowCaption="False" StateImageAlignment="Hidden" Width="106" FontSize="10" Foreground="DimGray"/>
this is my code so far. The Canvas-Part makes the Background go red.
I also tried to put the background property in the "FieldControl" but there it's useless.
EDIT:
After getting the information, that Data Binding could help me with this problem, i tested it like this:
<TextBox Canvas.Left="890" Canvas.Top="226" Name="Date" Width="99" Height="25" VerticalAlignment="Top" Text="{Binding ElementName=Date, Path = SelectedItem.Content, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}" Background="{Binding ElementName=Date, Path=SelectedItem.Content}">
But this is not the direction, i need. Do you have maybe any suggestion, how I can use Data binding to solve my problem?
Yes, it is possible. The concept you need to learn is XAML Data Binding.
You can implement the IValueConverter for this.
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/data-binding/converters
You can check the value on binding and return the background color.
how to give different text color for each item of listview in xamarin forms

OnPlatform in xamarin forms for input transparent property

I want input transperant to be true for ios and false for android i tried OnPlatform but i could not make it work
<PopupPage.InputTransparent>
<OnPlatform x:TypeArguments="false">
<OnPlatform.iOS>false</OnPlatform.iOS>
<OnPlatform.Android>true</OnPlatform.Android>
</OnPlatform>
</PopupPage.InputTransparent>
I am wondering what should i give in this place
<OnPlatform x:TypeArguments="false">
Any ideas are welcome.
The TypeArguments needs the type of the argument you're giving in the platform specific parts. Xamarin wants to know what the string value of "false" or "true" should be casted too. In this case that's a Boolean which means you should put down x:Boolean as the value.
<PopupPage.InputTransparent>
<OnPlatform x:TypeArguments="x:Boolean">
<OnPlatform.iOS>false</OnPlatform.iOS>
<OnPlatform.Android>true</OnPlatform.Android>
</OnPlatform>
</PopupPage.InputTransparent>
The "x:" part refers back to the namespace defined at the top of your XAML file:
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
I don't have much experience with OnPlatform but with OnIdiom at Typeargument you say which type your variabel is. For instance here for you it is Boolean
so try this:
<OnPlatform x:TypeArguments="x:Boolean">
Let me know if it works

Using multiple string resources from .resw file into ContentDialog

I would like to set the PrimaryButtonText, SecondaryButtonText and Title attributes of a ContentDialog with strings from my .resw file. Unfortunately Ι can do this only for one attribute using x:Uid, since setting x:Uid two times inside ContentDialog can not be accepted. I even tried to do something like that:
<ContentDialog>
<ContentDialog.PrimaryButtonText x:Uid="DialogConfirm" />
<ContentDialog.SecondaryButtonText x:Uid="DialogCancel" />
</ContentDialog>
But I got an exception
XBF generation error code 0x09c8
Is there any way to accomplish this?
Set x:Uid only for ContentDialog then in resources file set apropriate properties (take a look at MSDN):
<ContentDialog x:Uid="myDialog">
<!--your dialog-->
</ContentDialog>
In Resources.resw set:
myDialog.PrimaryButtonText -> text for primary button
myDialog.SecondaryButtonText -> text for secondary button
As for more guidelines and help, see MSDN.

Seam PDF - Aligning "p:data" keys to the left

I have the following code to generate a pdf from data:
<p:barchart is3D="true" legend="false" orientation="horizontal" width="520">
<p:series key="Gráfico">
<ui:repeat var="ocr" value="#{myBean.value}" >
<p:data key="#{ocr[0]}" value="#{ocr[1]}" />
</ui:repeat>
</p:series>
</p:barchart>
The problem is that the key from p:data gets aligned to the right (for some odd reason). I tried placing the code between divs with text-align, but it didn't worked.
I want the alignment to be on the left.
If someone has an answer, or at least an idea for me to try, I'd really appreciate.
Thanks in advance.
Is the value you're assigning an int or other numeric value? Trying casting it to a String instead.

XAML for floating window in AvalonDock

Can someone provide me with an AvalonDock XAML code piece that when run opens the app with a floating window instead of being always docked inside the dock pane? I've seen programmatic ways to do it, but I thought there must be a way to specify it in XAML. Thanks...
I know this is a bit late, but hopefully it will help someone with the same issue in the future...
To create a floating document, add a LayoutDocumentFloatingWindow as a child of LayoutDocumentFloatingWindow, and then add your LayoutDocument as a child of the LayoutDocumentFloatingWindow, as below:
<xcad:DockingManager>
<xcad:LayoutRoot>
<xcad:LayoutRoot.FloatingWindows>
<xcad:LayoutDocumentFloatingWindow>
<xcad:LayoutDocument Title="My Document">
<!--Add document content here-->
</xcad:LayoutDocument>
</xcad:LayoutDocumentFloatingWindow>
</xcad:LayoutRoot.FloatingWindows>
</xcad:LayoutRoot>
</xcad:DockingManager>
Similarly you can add anchorables like so:
<xcad:DockingManager>
<xcad:LayoutRoot>
<xcad:LayoutRoot.FloatingWindows>
<xcad:LayoutAnchorableFloatingWindow>
<xcad:LayoutAnchorablePaneGroup>
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable Title="My anchorable">
<!--Add anchorable content here-->
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutAnchorableFloatingWindow>
</xcad:LayoutRoot.FloatingWindows>
</xcad:LayoutRoot>
Note that unlike LayoutDocuments, for anchorables you need to add a group pane rather than just a single LayoutAnchorable, because floating anchorables are designed to be able to be grouped in a single window but LayoutDocuments are not.
As a more general guide, an example of how to set up varioius layout elements in a DockingManager can be found here: https://xceed.com/wp-content/documentation/xceed-toolkit-plus-for-wpf/AvalonDock.html