I'm building a Planning Poker UWP app for fun. I can style the poker cards (currently implemented as Buttons, via the Background property) using either an ImageBrush or a LinearGradientBrush without any issue, but obviously I can only set one type of brush to that property.
I'd like to style the card with an image, which then had another brush (e.g. a LinearGradientBrush) over-layed on top, this other brush would naturally have some degree of transparency so that parts of the image could show through.
How would you do that?
For the actual poker card that the user sees - I can re-implement that fairly easily using a different control type (e.g. a UserControl that combined several controls, each with their own background) but there are other instances of use (i.e. showing a list of the available styles), so I wanted to see if there way another way before looking into writing a custom UserControl.
Button is a content control, you can put other xaml controls in the button's content, and set LinearGradientBrush for them. For example,you can set ImageBrush for the button's background property, in the meanwhile set LinearGradientBrush for a Rectangle inline.
I'd like to style the card with an image, which then had another brush (e.g. a LinearGradientBrush) over-layed on top, this other brush would naturally have some degree of transparency so that parts of the image could show through.
To meet your requirement, I wrote a code example as follows:
<Button x:Name="BtnPoker" Padding="0">
<Rectangle Width="200"
Height="300"
Margin="0"
Opacity="0.4">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0.0" Color="Yellow" />
<GradientStop Offset="0.25" Color="Red" />
<GradientStop Offset="0.75" Color="Blue" />
<GradientStop Offset="1.0" Color="LimeGreen" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Button.Background>
<ImageBrush ImageSource="Assets\caffe.jpg" />
</Button.Background>
</Button>
And the result:
Related
I wants to create a form in a specified format where main window area will have some common links or buttons to all pages and the page area is where all the pages will be shown. Is this possible in wpf ?
Yes you can do that by using tab item and frames. You can have an idea using:
<TabItem Header="about" Name="aboutTab">
<TabControl>
<TabItem Header="REGISTRATION" Name="subTabRegistration">
<Grid>
<Frame NavigationUIVisibility="Hidden" VerticalAlignment="Top" HorizontalContentAlignment="Stretch" ClipToBounds="True" JournalOwnership="Automatic" Source="Pages/register-activate.xaml" x:Name="frameRegistration" />
</Grid>
</TabItem>
</TabControl>
</TabItem>
Currently I got a requirement to implement a control something like traditional masked text box. But unfortunately there is no first party control (some third party paid control is available like Component 1) available in uwp. If anybody has any idea to create the same please share.
You can make a TextBox background transparent and have a TextBlock behind it with your watermark text. Bind the visibility to the TextBox Text.IsEmpty property using a BooleanToVisibilityConverter
<Grid Grid.Row="0" Margin="5" Background="White">
<TextBlock VerticalAlignment="Center" Margin="3"
Foreground="SteelBlue"
Visibility="{Binding ElementName=MyTextBox, Path=Text.IsEmpty, Converter={StaticResource BooleanToVisibilityConverter}}">Type in here...</TextBlock>
<TextBox Background="Transparent"
x:Name="MyTextBox"/>
</Grid>
In your resources:
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
Have a look at PlaceHolderText Property on TextBox control.
I want to build custom slider with secondary progress on top of the primary progress chosen by the customer.
something like that in android: Changing Android SeekBar to draw secondary progress on top of primary progress?
Thanks
Like this:
<Grid VerticalAlignment="Top">
<ProgressBar Height="2" MinHeight="2"
Margin="0,-6,0,0" VerticalAlignment="Center"
Foreground="Silver" IsHitTestVisible="False"
Value="65" />
<Slider Background="Transparent" Value="35" />
</Grid>
Looks like this:
Sort of like the YouTube seek bar, right?
Best of luck!
When my application starts up I don't want a visible Chart as there's nothing that's been processed. I thought I can "hide" the Chart in an Expander - (simple minded, perhaps). The following code appears to break OxyPlot:
<StackPanel Grid.Row="0" Grid.Column="4" Orientation="Horizontal">
<Expander ExpandDirection="Right">
<oxy:Plot Grid.Row="0" Grid.Column="4" Title="Plot"
x:Name="ChartPlot" Title="Ein Grafik"
Model="{Binding PlotModel}">
</oxy:Plot>
</Expander>
</StackPanel>
What don't I understand about either the Expander or the OxyPlot control?
Or perhaps there are "better practices" to hide Content until it's ready?
Give your plot a size. As is, it thinks it has 0 space. Or enclose it in a grid that has a size.
I want to disply all my elipse in the same point using itemControl wpf. by default itemsControl use vertical stackpanel. there's a way to simply remove the StackPanel?
Thanks
Sure, you can give a custom ItemsPanel by either set one in your ItemsControl ControlTemplate, and using the IsItemsHost property to tell which of the panels is the receiver of the items.
<ItemsControl.Template>
<ControlTemplate>
<Canvas IsItemsHost="True"/>
</ControlTemplate>
</ItemsControl.Template>
or by supplying a custom ItemsPanel and telling the position in the template by an ItemsPresenter.
<ItemsControl.Template>
<ControlTemplate>
<ItemsPresenter/>
</ControlTemplate>
</ItemsControl.Template>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>