lawang code

lawang Code


Tanyakan kode disini

Cara mengganti warna datagrid wpf dengan kondisi

oleh handita okviyanto 4 tahun yang lalu

Ini contoh styling datagrid yang memakai styling warna dengan binding property masing masing.

ubah gambar datagrid wpf

 <Style TargetType="{x:Type DataGridCell}">
    <Style.Triggers>
        <DataTrigger Binding="{Binding MasterRT.StatusDokKor}" Value="E">
            <Setter Property="Foreground" Value="#FFF11D1D" />
        </DataTrigger>
        <DataTrigger Binding="{Binding MasterRT.StatusDokKor}" Value="C">
            <Setter Property="Foreground" Value="#00A388" />
        </DataTrigger>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding Path=MasterRT.StatusDokKor}" Value="E" />
                <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Background" Value="#FFF11D1D" />
            <Setter Property="Foreground" Value="White" />
        </MultiDataTrigger>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding Path=MasterRT.StatusDokKor}" Value="C" />
                <Condition Binding="{Binding Path=IsSelected, RelativeSource={RelativeSource Self}}" Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Background" Value="#00A388" />
            <Setter Property="Foreground" Value="White" />
        </MultiDataTrigger>
    </Style.Triggers>
</Style>

Untuk gambar juga bisa memakai style seperti ini :

<Style x:Key="ChangeImageKor" TargetType="{x:Type Image}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding MasterRT.IsLockedKor}" Value="1">
                <Setter Property="Source" Value="/Susenas2015;component/Assets/lock.png"/>
                <Setter Property="Visibility" Value="Visible"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding IsLockedKor}" Value="0">
                <Setter Property="Source" Value="/Susenas2015;component/Assets/lock.png"/>
                <Setter Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
</DataGrid.Resources>


C# WPF datagrid
Anda harus login terlebih dahulu untuk memberikan komentar

Recent Tag

X 5
X 6
X 1
X 21
X 2
X 3
X 1
X 260
X 1

Bantuan

Help

Feedback

Help